| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace Opentalent\OtTemplating\ViewHelpers\RootPage;
- use Closure;
- use Opentalent\OtCore\Page\OtPageRepository;
- use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
- use TYPO3\CMS\Core\Utility\GeneralUtility;
- use TYPO3\CMS\Extbase\Object\ObjectManager;
- use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
- /**
- * Viewhelper to retrieve the Id of the current site root page
- * Call it in fluid templates with:
- *
- * {namespace ot=Opentalent\OtTemplating\ViewHelpers}
- *
- * {ot:rootPage.getId()}
- *
- * @package Opentalent\OtTemplating\ViewHelpers
- */
- class GetIdViewHelper extends OtAbstractViewHelper
- {
- /**
- * -- 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
- ) {
- $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtPageRepository::class);
- return $pageRepository->getCurrentSiteRootPageId();
- }
- }
|