| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace Opentalent\OtTemplating\ViewHelpers\EventsPage;
- use Closure;
- use Opentalent\OtTemplating\Page\OtPageRepository;
- use TYPO3\CMS\Core\Utility\GeneralUtility;
- use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
- use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
- /**
- * Retrieves and returns the uid of the events' page of the current site
- * The events page is the first page found with the template 'OpenTalent.OtTemplating->events'
- * Returns 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
- {
- /**
- * -- This method is expected by Fluid --
- * Renders the content as html
- *
- * @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 = GeneralUtility::makeInstance(OtPageRepository::class);
- $subpages = $pageRepository->getAllSubpagesForPage($rootId);
- foreach ($subpages as $page) {
- if ($page['tx_fed_page_controller_action'] === 'OpenTalent.OtTemplating->events') {
- return $page['uid'];
- }
- }
- return null;
- }
- }
|