mirror of
https://github.com/werkraum-media/events.git
synced 2024-12-23 07:06:09 +01:00
Daniel Siepmann
17bd83eedf
Allow editors to select specific events to display. Therefore add new necessary demand and setting for events and respect them within repository. Relates: #8092
151 lines
3.8 KiB
PHP
151 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace Wrm\Events\Controller;
|
|
|
|
use TYPO3\CMS\Core\Database\QueryGenerator;
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
use TYPO3\CMS\Extbase\Annotation as Extbase;
|
|
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
|
use Wrm\Events\Domain\Model\Dto\EventDemand;
|
|
use Wrm\Events\Domain\Model\Event;
|
|
use Wrm\Events\Domain\Repository\EventRepository;
|
|
use Wrm\Events\Service\DataProcessingForModels;
|
|
|
|
/**
|
|
* EventController
|
|
*/
|
|
|
|
class EventController extends ActionController
|
|
{
|
|
|
|
/**
|
|
* @var eventRepository
|
|
*/
|
|
protected $eventRepository = null;
|
|
|
|
/**
|
|
* @var QueryGenerator
|
|
*/
|
|
protected $queryGenerator;
|
|
|
|
/**
|
|
* @var DataProcessingForModels
|
|
*/
|
|
protected $dataProcessing;
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $pluginSettings;
|
|
|
|
/**
|
|
* @param EventRepository $eventRepository
|
|
*/
|
|
public function injectEventRepository(EventRepository $eventRepository)
|
|
{
|
|
$this->eventRepository = $eventRepository;
|
|
}
|
|
|
|
/**
|
|
* @param DataProcessingForModels $dataProcessing
|
|
*/
|
|
public function injectDataProcessingForModels(DataProcessingForModels $dataProcessing)
|
|
{
|
|
$this->dataProcessing = $dataProcessing;
|
|
}
|
|
|
|
/**
|
|
* Action initializer
|
|
*/
|
|
protected function initializeAction()
|
|
{
|
|
$this->dataProcessing->setConfigurationManager($this->configurationManager);
|
|
$this->pluginSettings = $this->configurationManager->getConfiguration(
|
|
ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Action list
|
|
*
|
|
* @return void
|
|
*/
|
|
public function listAction()
|
|
{
|
|
|
|
$demand = $this->createDemandFromSettings();
|
|
$events = $this->eventRepository->findByDemand($demand);
|
|
$this->view->assign('events', $events);
|
|
}
|
|
|
|
/**
|
|
* Action show
|
|
*
|
|
* @Extbase\IgnoreValidation("event")
|
|
*
|
|
* @param Event $event
|
|
* @return void
|
|
*/
|
|
public function showAction(Event $event)
|
|
{
|
|
$this->view->assign('event', $event);
|
|
}
|
|
|
|
/**
|
|
* action teaser
|
|
*
|
|
* @return void
|
|
*/
|
|
public function teaserAction()
|
|
{
|
|
$events = $this->eventRepository->findByUids($this->settings['eventUids']);
|
|
$this->view->assign('events', $events);
|
|
}
|
|
|
|
/**
|
|
* @param string $search
|
|
*/
|
|
public function searchAction(): void
|
|
{
|
|
$search = '';
|
|
if ($this->request->hasArgument('search')) {
|
|
$search = $this->request->getArgument('search');
|
|
}
|
|
|
|
$this->view->assign('search', $search);
|
|
$this->view->assign('events', $this->eventRepository->findSearchWord($search));
|
|
}
|
|
|
|
/**
|
|
* @return EventDemand
|
|
*/
|
|
|
|
protected function createDemandFromSettings(): EventDemand
|
|
{
|
|
/** @var EventDemand $demand */
|
|
$demand = $this->objectManager->get(EventDemand::class);
|
|
|
|
$demand->setRegion((string)$this->settings['region']);
|
|
|
|
$demand->setCategories((string)$this->settings['categories']);
|
|
$categoryCombination = (int)$this->settings['categoryCombination'] === 1 ? 'or' : 'and';
|
|
|
|
$demand->setCategoryCombination($categoryCombination);
|
|
|
|
$demand->setIncludeSubCategories((bool)$this->settings['includeSubcategories']);
|
|
|
|
$demand->setSortBy((string)$this->settings['sortByEvent']);
|
|
$demand->setSortOrder((string)$this->settings['sortOrder']);
|
|
|
|
$demand->setHighlight((bool)$this->settings['highlight']);
|
|
|
|
$demand->setRecordUids(GeneralUtility::intExplode(',', $this->settings['selectedRecords'], true));
|
|
|
|
if (!empty($this->settings['limit'])) {
|
|
$demand->setLimit($this->settings['limit']);
|
|
}
|
|
|
|
return $demand;
|
|
}
|
|
}
|