| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace Opentalent\OtTemplating\ViewHelpers\RootPage;
- use Closure;
- use Opentalent\OtCore\Exception\NoSuchWebsiteException;
- use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
- use Opentalent\OtCore\Website\OtWebsiteRepository;
- 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
- {
- public function __construct(
- private readonly OtWebsiteRepository $otWebsiteRepository,
- ) {}
- /**
- * -- This method is expected by Fluid --
- * Renders the content as html
- *
- * @return int|null
- * @throws NoSuchWebsiteException
- */
- public function render(): ?int
- {
- return $this->otWebsiteRepository->getCurrentRootpageUidFromFEGlobals();
- }
- }
|