blob: b4ffce522ffb0b02f52686d26919c66e749b9a24 [file] [log] [blame]
BacLuc955e1262020-03-15 11:13:38 +01001<?php
2
3
4namespace BaclucEventPackage\NextEvent;
5
6
BacLucfaa423d2020-03-15 13:41:56 +01007use BaclucC5Crud\Entity\ConfigurationSupplier;
BacLuc955e1262020-03-15 11:13:38 +01008use BaclucC5Crud\Entity\TableViewEntrySupplier;
9use BaclucEventPackage\EventRepository;
BacLucfaa423d2020-03-15 13:41:56 +010010use function BaclucC5Crud\Lib\collect as collect;
BacLuc955e1262020-03-15 11:13:38 +010011
12class ShowNextEventEntrySupplier implements TableViewEntrySupplier
13{
14 /**
15 * @var EventRepository
16 */
17 private $eventRepository;
BacLucfaa423d2020-03-15 13:41:56 +010018 /**
19 * @var ConfigurationSupplier
20 */
21 private $configurationSupplier;
BacLuc955e1262020-03-15 11:13:38 +010022
23
BacLucfaa423d2020-03-15 13:41:56 +010024 public function __construct(EventRepository $eventRepository, ConfigurationSupplier $configurationSupplier)
BacLuc955e1262020-03-15 11:13:38 +010025 {
26 $this->eventRepository = $eventRepository;
BacLucfaa423d2020-03-15 13:41:56 +010027 $this->configurationSupplier = $configurationSupplier;
BacLuc955e1262020-03-15 11:13:38 +010028 }
29
30 public function getEntries()
31 {
BacLucfaa423d2020-03-15 13:41:56 +010032 /** @var NextEventConfiguration $configuration */
33 $configuration = $this->configurationSupplier->getConfiguration();
34 return $this->eventRepository->getLastEventOfGroup(collect($configuration->showNextEventOfGroups)
35 ->map(function ($group) {
36 return $group->gID;
37 })
38 ->toArray());
BacLuc955e1262020-03-15 11:13:38 +010039 }
BacLucb1333982020-04-29 21:27:52 +020040
41 public function count()
42 {
43 return 1;
44 }
BacLuc955e1262020-03-15 11:13:38 +010045}