| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace Opentalent\OtTemplating\ViewHelpers\Events;
- use FluidTYPO3\Vhs\Traits\TemplateVariableViewHelperTrait;
- use Opentalent\OtTemplating\Domain\Repository\EventRepository;
- use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
- /**
- * This view helper provides an array named according to the 'as' variable
- * and which contains the next events of the structure
- *
- * {namespace ot=Opentalent\OtTemplating\ViewHelpers}
- *
- * <ot:events.getAll as="events"
- * organizationId="{settings.organizationId}">
- * <f:debug>{events}</f:debug>
- * </ot:events.getAll>
- *
- * @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 = [];
- // $args = $this->request->getArguments();
- // if($args['search-loc']) {
- // $searchParams['where'] = $args['search-loc'];
- // }
- // if($args['search-name']) {
- // $searchParams['what'] = $args['search-name'];
- // }
- // if($args['search-datestart']) {
- // $dateStart = \DateTime::createFromFormat('d/m/Y', $args['search-datestart']);
- // $searchParams['datetimeStart'] = $dateStart->format('d-m-Y');
- // }
- // if($args['search-dateend']) {
- // $dateEnd = \DateTime::createFromFormat('d/m/Y', $args['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;
- }
- }
|