2019-07-18 13:44:19 +02:00
|
|
|
<?php
|
2021-01-07 08:50:43 +01:00
|
|
|
|
2019-07-18 13:44:19 +02:00
|
|
|
namespace Wrm\Events\Controller;
|
|
|
|
|
2021-01-07 08:58:03 +01:00
|
|
|
use TYPO3\CMS\Core\Database\QueryGenerator;
|
2019-11-11 12:43:50 +01:00
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
2021-01-11 09:20:51 +01:00
|
|
|
use TYPO3\CMS\Extbase\Annotation as Extbase;
|
2021-01-07 08:58:03 +01:00
|
|
|
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
|
|
|
use Wrm\Events\Domain\Model\Date;
|
2019-07-18 13:44:19 +02:00
|
|
|
use Wrm\Events\Domain\Model\Dto\DateDemand;
|
2021-12-06 12:14:19 +01:00
|
|
|
use Wrm\Events\Domain\Model\Dto\DateDemandFactory;
|
2021-07-13 15:50:14 +02:00
|
|
|
use Wrm\Events\Domain\Repository\CategoryRepository;
|
2019-07-18 13:44:19 +02:00
|
|
|
use Wrm\Events\Domain\Repository\DateRepository;
|
2019-08-14 17:22:01 +02:00
|
|
|
use Wrm\Events\Domain\Repository\RegionRepository;
|
2021-01-11 09:20:51 +01:00
|
|
|
use Wrm\Events\Service\DataProcessingForModels;
|
2019-07-18 13:44:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* DateController
|
|
|
|
*/
|
2021-06-16 11:19:11 +02:00
|
|
|
class DateController extends AbstractController
|
2019-07-18 13:44:19 +02:00
|
|
|
{
|
2021-12-06 12:14:19 +01:00
|
|
|
/**
|
|
|
|
* @var DateDemandFactory
|
|
|
|
*/
|
|
|
|
protected $demandFactory;
|
|
|
|
|
2019-07-18 13:44:19 +02:00
|
|
|
/**
|
|
|
|
* @var dateRepository
|
|
|
|
*/
|
2019-08-14 17:22:01 +02:00
|
|
|
protected $dateRepository;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var regionRepository
|
|
|
|
*/
|
|
|
|
protected $regionRepository;
|
2019-07-18 13:44:19 +02:00
|
|
|
|
2021-07-13 15:50:14 +02:00
|
|
|
/**
|
|
|
|
* @var CategoryRepository
|
|
|
|
*/
|
|
|
|
protected $categoryRepository;
|
|
|
|
|
2019-07-18 13:44:19 +02:00
|
|
|
/**
|
|
|
|
* @var QueryGenerator
|
|
|
|
*/
|
|
|
|
protected $queryGenerator;
|
|
|
|
|
2021-01-11 09:20:51 +01:00
|
|
|
/**
|
|
|
|
* @var DataProcessingForModels
|
|
|
|
*/
|
|
|
|
protected $dataProcessing;
|
|
|
|
|
2019-07-18 13:44:19 +02:00
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $pluginSettings;
|
|
|
|
|
2019-08-14 17:22:01 +02:00
|
|
|
/*
|
|
|
|
* @param RegionRepository $regionRepository
|
2019-07-18 13:44:19 +02:00
|
|
|
* @param DateRepository $dateRepository
|
2021-07-13 15:50:14 +02:00
|
|
|
* @param CategoryRepository $categoryRepository
|
2019-07-18 13:44:19 +02:00
|
|
|
*/
|
2019-08-14 17:22:01 +02:00
|
|
|
public function __construct(
|
2021-12-06 12:14:19 +01:00
|
|
|
DateDemandFactory $demandFactory,
|
2019-08-14 17:22:01 +02:00
|
|
|
RegionRepository $regionRepository,
|
2021-07-13 15:50:14 +02:00
|
|
|
DateRepository $dateRepository,
|
|
|
|
CategoryRepository $categoryRepository
|
2019-08-14 17:22:01 +02:00
|
|
|
) {
|
2021-12-06 12:14:19 +01:00
|
|
|
$this->demandFactory = $demandFactory;
|
2019-08-14 17:22:01 +02:00
|
|
|
$this->regionRepository = $regionRepository;
|
2019-07-18 13:44:19 +02:00
|
|
|
$this->dateRepository = $dateRepository;
|
2021-07-13 15:50:14 +02:00
|
|
|
$this->categoryRepository = $categoryRepository;
|
2019-07-18 13:44:19 +02:00
|
|
|
}
|
|
|
|
|
2021-01-11 09:20:51 +01:00
|
|
|
/**
|
|
|
|
* @param DataProcessingForModels $dataProcessing
|
|
|
|
*/
|
2021-09-07 09:52:14 +02:00
|
|
|
public function injectDataProcessingForModels(DataProcessingForModels $dataProcessing): void
|
2021-01-11 09:20:51 +01:00
|
|
|
{
|
|
|
|
$this->dataProcessing = $dataProcessing;
|
|
|
|
}
|
|
|
|
|
2021-09-07 09:52:14 +02:00
|
|
|
protected function initializeAction(): void
|
2019-07-18 13:44:19 +02:00
|
|
|
{
|
2021-12-06 12:14:19 +01:00
|
|
|
$contentObject = $this->configurationManager->getContentObject();
|
|
|
|
if ($contentObject !== null) {
|
|
|
|
$this->demandFactory->setContentObjectRenderer($contentObject);
|
|
|
|
}
|
2021-01-11 09:20:51 +01:00
|
|
|
$this->dataProcessing->setConfigurationManager($this->configurationManager);
|
2019-07-18 13:44:19 +02:00
|
|
|
$this->pluginSettings = $this->configurationManager->getConfiguration(
|
|
|
|
ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-06-28 11:38:55 +02:00
|
|
|
/**
|
|
|
|
* @param array $search
|
|
|
|
*/
|
|
|
|
public function listAction(array $search = []): void
|
2019-07-18 13:44:19 +02:00
|
|
|
{
|
2022-06-28 11:38:55 +02:00
|
|
|
if ($search !== []) {
|
|
|
|
$demand = DateDemand::createFromRequestValues($search, $this->settings);
|
|
|
|
} elseif (
|
2021-07-13 15:50:14 +02:00
|
|
|
($this->request->hasArgument('searchword') && $this->request->getArgument('searchword') != '')
|
|
|
|
|| ($this->request->hasArgument('region') && $this->request->getArgument('region') != '')
|
|
|
|
|| ($this->request->hasArgument('start') && $this->request->getArgument('start') != '')
|
|
|
|
|| ($this->request->hasArgument('end') && $this->request->getArgument('end') != '')
|
|
|
|
|| ($this->request->hasArgument('events_search') && $this->request->getArgument('events_search') != [])
|
|
|
|
) {
|
2019-11-11 12:43:50 +01:00
|
|
|
$demand = $this->createDemandFromSearch();
|
|
|
|
} else {
|
2021-12-06 12:14:19 +01:00
|
|
|
$demand = $this->demandFactory->fromSettings($this->settings);
|
2019-11-11 12:43:50 +01:00
|
|
|
}
|
2022-06-28 11:38:55 +02:00
|
|
|
|
|
|
|
$this->view->assignMultiple([
|
|
|
|
'search' => $search,
|
|
|
|
'demand' => $demand,
|
|
|
|
'dates' => $this->dateRepository->findByDemand($demand),
|
|
|
|
]);
|
2019-07-18 13:44:19 +02:00
|
|
|
}
|
|
|
|
|
2022-06-28 11:38:55 +02:00
|
|
|
/**
|
|
|
|
* @param array $search
|
|
|
|
*/
|
|
|
|
public function searchAction(array $search = []): void
|
2019-08-14 17:22:01 +02:00
|
|
|
{
|
2022-06-28 11:38:55 +02:00
|
|
|
$arguments = GeneralUtility::_GET('tx_events_datelist') ?? $search;
|
2021-12-13 09:09:13 +01:00
|
|
|
if (is_array($arguments) === false) {
|
|
|
|
$arguments = [];
|
|
|
|
}
|
2022-06-28 11:38:55 +02:00
|
|
|
if (isset($arguments['events_search']) && is_array($arguments['events_search'])) {
|
2021-07-13 15:50:14 +02:00
|
|
|
$arguments += $arguments['events_search'];
|
|
|
|
unset($arguments['events_search']);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->view->assignMultiple([
|
|
|
|
'searchword' => $arguments['searchword'] ?? '',
|
|
|
|
'selRegion' => $arguments['region'] ?? '',
|
|
|
|
'start' => $arguments['start'] ?? '',
|
|
|
|
'end' => $arguments['end'] ?? '',
|
|
|
|
'considerDate' => $arguments['considerDate'] ?? '',
|
2022-06-28 11:38:55 +02:00
|
|
|
'search' => $search,
|
2021-07-13 15:50:14 +02:00
|
|
|
'demand' => DateDemand::createFromRequestValues($arguments, $this->settings),
|
|
|
|
'regions' => $this->regionRepository->findAll(),
|
2022-07-05 14:08:14 +02:00
|
|
|
'categories' => $this->categoryRepository->findAllCurrentlyAssigned($this->settings['uids']['categoriesParent'] ?? 0, 'categories'),
|
|
|
|
'features' => $this->categoryRepository->findAllCurrentlyAssigned($this->settings['uids']['featuresParent'] ?? 0, 'features'),
|
2021-07-13 15:50:14 +02:00
|
|
|
]);
|
2019-08-14 17:22:01 +02:00
|
|
|
}
|
|
|
|
|
2021-09-07 09:52:14 +02:00
|
|
|
public function teaserAction(): void
|
2019-07-18 13:44:19 +02:00
|
|
|
{
|
|
|
|
$dates = $this->dateRepository->findByUids($this->settings['eventUids']);
|
|
|
|
$this->view->assign('dates', $dates);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-01-11 09:20:51 +01:00
|
|
|
* @Extbase\IgnoreValidation("date")
|
2019-07-18 13:44:19 +02:00
|
|
|
*/
|
2021-09-07 09:52:14 +02:00
|
|
|
public function showAction(Date $date): void
|
2019-07-18 13:44:19 +02:00
|
|
|
{
|
|
|
|
$this->view->assign('date', $date);
|
|
|
|
}
|
|
|
|
|
2019-08-14 17:22:01 +02:00
|
|
|
protected function createDemandFromSearch(): DateDemand
|
|
|
|
{
|
2021-12-13 09:09:13 +01:00
|
|
|
$arguments = $this->request->getArguments();
|
2021-07-13 15:50:14 +02:00
|
|
|
if (isset($arguments['events_search'])) {
|
|
|
|
$arguments += $arguments['events_search'];
|
|
|
|
unset($arguments['events_search']);
|
2019-07-18 13:44:19 +02:00
|
|
|
}
|
|
|
|
|
2021-07-13 15:50:14 +02:00
|
|
|
return DateDemand::createFromRequestValues(
|
|
|
|
$arguments,
|
|
|
|
$this->settings
|
|
|
|
);
|
2019-07-18 13:44:19 +02:00
|
|
|
}
|
|
|
|
}
|