events/Classes/Controller/EventController.php
Daniel Siepmann 1e98df689b 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
2024-07-23 14:05:13 +02:00

85 lines
2.4 KiB
PHP

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