events/Classes/Controller/EventController.php
Daniel Siepmann 713bc4b697
Add meta tags (#49)
A new class is added which will add meta tags for dates and events.
The class has an interface which allows it to be replaced via DI to
alter behaviour.

Refactor import regarding data handler. We now also need to add a new
column "keywords". We use the new DataHandler approach.
But that approach only covered relations so far. We therefore refactor
that area to be more generic and use that one for new keywords column.

Relates: #10642
2023-11-29 10:36:59 +01:00

66 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
namespace WerkraumMedia\Events\Controller;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Extbase\Annotation as Extbase;
use WerkraumMedia\Events\Domain\Model\Dto\EventDemandFactory;
use WerkraumMedia\Events\Domain\Model\Event;
use WerkraumMedia\Events\Domain\Repository\EventRepository;
use WerkraumMedia\Events\Frontend\MetaInformation\EventMetaInformationInterface;
use WerkraumMedia\Events\Service\DataProcessingForModels;
final class EventController extends AbstractController
{
public function __construct(
private readonly EventRepository $eventRepository,
private readonly DataProcessingForModels $dataProcessing,
private readonly EventDemandFactory $demandFactory,
private readonly EventMetaInformationInterface $metaInformationService
) {
}
protected function initializeAction(): void
{
parent::initializeAction();
$this->dataProcessing->setConfigurationManager($this->configurationManager);
}
public function listAction(): ResponseInterface
{
$demand = $this->demandFactory->fromSettings($this->settings);
$events = $this->eventRepository->findByDemand($demand);
$this->view->assign('events', $events);
return $this->htmlResponse();
}
#[Extbase\IgnoreValidation(['value' => 'event'])]
public function showAction(Event $event): ResponseInterface
{
$this->metaInformationService->setEvent($event);
$this->view->assign('event', $event);
return $this->htmlResponse();
}
/**
* @deprecated Use listAction instead and configure settings properly.
* Use Settings or something else to switch between list and teaser rendering.
*/
public function teaserAction(): ResponseInterface
{
$this->view->assignMultiple([
'events' => $this->eventRepository->findByUids($this->settings['eventUids']),
]);
return $this->htmlResponse();
}
public function searchAction(string $search = ''): ResponseInterface
{
$this->view->assign('search', $search);
$this->view->assign('events', $this->eventRepository->findSearchWord($search));
return $this->htmlResponse();
}
}