| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace Opentalent\OtTemplating\ViewHelpers\EventsPage;
- use Opentalent\OtTemplating\Page\OtPageRepository;
- use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
- use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
- /**
- * Viewhelper to retrieve the Id of the current site events page
- * The events page is the first page found which has the template 'OpenTalent.OtTemplating->events'
- * Return null if no such page is found
- *
- * Call it in fluid templates with:
- *
- * {namespace ot=Opentalent\OtTemplating\ViewHelpers}
- *
- * {ot:eventsPage.getId()}
- *
- * @package Opentalent\OtTemplating\ViewHelpers
- */
- class GetIdViewHelper extends AbstractViewHelper
- {
- public function initializeArguments()
- {
- }
- /**
- * @param array $arguments
- * @param \Closure $renderChildrenClosure
- * @param RenderingContextInterface $renderingContext
- * @return int|null
- */
- public static function renderStatic(
- array $arguments,
- \Closure $renderChildrenClosure,
- RenderingContextInterface $renderingContext
- ) {
- $rootId = \Opentalent\OtTemplating\ViewHelpers\RootPage\GetIdViewHelper::renderStatic(
- $arguments,
- $renderChildrenClosure,
- $renderingContext
- );
- $pageRepository = new OtPageRepository();
- $subpages = $pageRepository->getAllSubpagesForPage($rootId);
- foreach ($subpages as $page) {
- if ($page['tx_fed_page_controller_action'] === 'OpenTalent.OtTemplating->events') {
- return $page['uid'];
- }
- }
- return null;
- }
- }
|