BacLuc | 955e126 | 2020-03-15 11:13:38 +0100 | [diff] [blame] | 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace BaclucEventPackage\NextEvent; |
| 5 | |
| 6 | |
BacLuc | faa423d | 2020-03-15 13:41:56 +0100 | [diff] [blame] | 7 | use BaclucC5Crud\Entity\ConfigurationSupplier; |
BacLuc | 955e126 | 2020-03-15 11:13:38 +0100 | [diff] [blame] | 8 | use BaclucC5Crud\Entity\TableViewEntrySupplier; |
| 9 | use BaclucEventPackage\EventRepository; |
BacLuc | faa423d | 2020-03-15 13:41:56 +0100 | [diff] [blame] | 10 | use function BaclucC5Crud\Lib\collect as collect; |
BacLuc | 955e126 | 2020-03-15 11:13:38 +0100 | [diff] [blame] | 11 | |
| 12 | class ShowNextEventEntrySupplier implements TableViewEntrySupplier |
| 13 | { |
| 14 | /** |
| 15 | * @var EventRepository |
| 16 | */ |
| 17 | private $eventRepository; |
BacLuc | faa423d | 2020-03-15 13:41:56 +0100 | [diff] [blame] | 18 | /** |
| 19 | * @var ConfigurationSupplier |
| 20 | */ |
| 21 | private $configurationSupplier; |
BacLuc | 955e126 | 2020-03-15 11:13:38 +0100 | [diff] [blame] | 22 | |
| 23 | |
BacLuc | faa423d | 2020-03-15 13:41:56 +0100 | [diff] [blame] | 24 | public function __construct(EventRepository $eventRepository, ConfigurationSupplier $configurationSupplier) |
BacLuc | 955e126 | 2020-03-15 11:13:38 +0100 | [diff] [blame] | 25 | { |
| 26 | $this->eventRepository = $eventRepository; |
BacLuc | faa423d | 2020-03-15 13:41:56 +0100 | [diff] [blame] | 27 | $this->configurationSupplier = $configurationSupplier; |
BacLuc | 955e126 | 2020-03-15 11:13:38 +0100 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | public function getEntries() |
| 31 | { |
BacLuc | faa423d | 2020-03-15 13:41:56 +0100 | [diff] [blame] | 32 | /** @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()); |
BacLuc | 955e126 | 2020-03-15 11:13:38 +0100 | [diff] [blame] | 39 | } |
BacLuc | b133398 | 2020-04-29 21:27:52 +0200 | [diff] [blame^] | 40 | |
| 41 | public function count() |
| 42 | { |
| 43 | return 1; |
| 44 | } |
BacLuc | 955e126 | 2020-03-15 11:13:38 +0100 | [diff] [blame] | 45 | } |