2019-07-18 13:44:19 +02:00
|
|
|
<?php
|
2021-01-07 08:50:43 +01:00
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2023-11-09 10:27:43 +01:00
|
|
|
namespace WerkraumMedia\Events\Controller;
|
2019-07-18 13:44:19 +02:00
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
use Psr\Http\Message\ResponseInterface;
|
2021-01-11 09:20:51 +01:00
|
|
|
use TYPO3\CMS\Extbase\Annotation as Extbase;
|
2023-11-09 10:27:43 +01:00
|
|
|
use WerkraumMedia\Events\Domain\Model\Dto\EventDemandFactory;
|
|
|
|
use WerkraumMedia\Events\Domain\Model\Event;
|
|
|
|
use WerkraumMedia\Events\Domain\Repository\EventRepository;
|
|
|
|
use WerkraumMedia\Events\Service\DataProcessingForModels;
|
2019-07-18 13:44:19 +02:00
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
final class EventController extends AbstractController
|
2019-07-18 13:44:19 +02:00
|
|
|
{
|
2021-01-12 14:34:13 +01:00
|
|
|
public function __construct(
|
2023-11-27 10:04:42 +01:00
|
|
|
private readonly EventRepository $eventRepository,
|
|
|
|
private readonly DataProcessingForModels $dataProcessing,
|
|
|
|
private readonly EventDemandFactory $demandFactory
|
2021-01-12 14:34:13 +01:00
|
|
|
) {
|
2021-01-11 09:20:51 +01:00
|
|
|
}
|
|
|
|
|
2021-09-07 09:52:14 +02:00
|
|
|
protected function initializeAction(): void
|
2019-07-18 13:44:19 +02:00
|
|
|
{
|
2023-06-19 10:13:26 +02:00
|
|
|
parent::initializeAction();
|
|
|
|
|
2021-01-11 09:20:51 +01:00
|
|
|
$this->dataProcessing->setConfigurationManager($this->configurationManager);
|
2019-07-18 13:44:19 +02:00
|
|
|
}
|
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
public function listAction(): ResponseInterface
|
2019-07-18 13:44:19 +02:00
|
|
|
{
|
2021-01-12 14:34:13 +01:00
|
|
|
$demand = $this->demandFactory->fromSettings($this->settings);
|
2019-07-18 13:44:19 +02:00
|
|
|
$events = $this->eventRepository->findByDemand($demand);
|
|
|
|
$this->view->assign('events', $events);
|
2023-11-27 10:04:42 +01:00
|
|
|
return $this->htmlResponse();
|
2019-07-18 13:44:19 +02:00
|
|
|
}
|
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
#[Extbase\IgnoreValidation(['value' => 'event'])]
|
|
|
|
public function showAction(Event $event): ResponseInterface
|
2019-07-18 13:44:19 +02:00
|
|
|
{
|
|
|
|
$this->view->assign('event', $event);
|
2023-11-27 10:04:42 +01:00
|
|
|
return $this->htmlResponse();
|
2019-07-18 13:44:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-12 14:34:13 +01:00
|
|
|
* @deprecated Use listAction instead and configure settings properly.
|
|
|
|
* Use Settings or something else to switch between list and teaser rendering.
|
2019-07-18 13:44:19 +02:00
|
|
|
*/
|
2023-11-27 10:04:42 +01:00
|
|
|
public function teaserAction(): ResponseInterface
|
2019-07-18 13:44:19 +02:00
|
|
|
{
|
2021-01-12 14:34:13 +01:00
|
|
|
$this->view->assignMultiple([
|
|
|
|
'events' => $this->eventRepository->findByUids($this->settings['eventUids']),
|
|
|
|
]);
|
2023-11-27 10:04:42 +01:00
|
|
|
return $this->htmlResponse();
|
2019-07-18 13:44:19 +02:00
|
|
|
}
|
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
public function searchAction(string $search = ''): ResponseInterface
|
2019-08-14 17:22:01 +02:00
|
|
|
{
|
|
|
|
$this->view->assign('search', $search);
|
|
|
|
$this->view->assign('events', $this->eventRepository->findSearchWord($search));
|
2023-11-27 10:04:42 +01:00
|
|
|
return $this->htmlResponse();
|
2019-08-14 17:22:01 +02:00
|
|
|
}
|
2019-07-18 13:44:19 +02:00
|
|
|
}
|