* {events} * * * @package Opentalent\OtTemplating\ViewHelpers */ class GetAllViewHelper extends AbstractViewHelper { use TemplateVariableViewHelperTrait; /** * >> Required to prevent typo3 to escape the html output * @var boolean */ protected $escapeOutput = false; /** * @var \Opentalent\OtTemplating\Domain\Repository\EventRepository * */ protected $eventRepository; public function initializeArguments() { $this->registerArgument( 'as', 'string', 'Name of the returned array', true ); $this->registerArgument( 'organizationId', 'integer', 'Id of the current structure', true ); } /** * @return string */ public function render() { // Get current settings $as = $this->arguments['as']; $organizationId = $this->arguments['organizationId']; $searchParams = []; if($_REQUEST['search-loc']) { $searchParams['where'] = $_REQUEST['search-loc']; } if($_REQUEST['search-name']) { $searchParams['what'] = $_REQUEST['search-name']; } if($_REQUEST['search-datestart']) { $dateStart = \DateTime::createFromFormat('d/m/Y', $_REQUEST['search-datestart']); $searchParams['datetimeStart'] = $dateStart->format('d-m-Y'); } if($_REQUEST['search-dateend']) { $dateEnd = \DateTime::createFromFormat('d/m/Y', $_REQUEST['search-dateend']); $searchParams['datetimeEnd'] = $dateEnd->format('d-m-Y'); } $events = $this->eventRepository->searchBy($organizationId, $searchParams); $variables = [$as => $events]; return $this->renderChildrenWithVariables($variables); } /** * @param \Opentalent\OtTemplating\Domain\Repository\EventRepository $eventRepository */ public function injectEventRepository(EventRepository $eventRepository) { $this->eventRepository = $eventRepository; } }