| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace Opentalent\OtTemplating\ViewHelpers\RootPage;
- use Closure;
- use Opentalent\OtCore\Exception\InvalidWebsiteConfigurationException;
- 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 Uri of the root page of the current site
- * Call it in fluid templates with:
- *
- * {namespace ot=Opentalent\OtTemplating\ViewHelpers}
- *
- * {ot:rootPage.getUri()}
- *
- * @package Opentalent\OtTemplating\ViewHelpers
- */
- class GetUriViewHelper extends OtAbstractViewHelper
- {
- public function __construct(
- private readonly OtWebsiteRepository $otWebsiteRepository,
- ) {}
- /**
- * -- This method is expected by Fluid --
- * Renders the content as html
- *
- * @return string
- * @throws InvalidWebsiteConfigurationException
- * @throws NoSuchWebsiteException
- */
- public function render(): string
- {
- return $this->otWebsiteRepository->getCurrentSiteRootUriFromFeGlobals();
- }
- }
|