GetUriViewHelper.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Opentalent\OtTemplating\ViewHelpers\RootPage;
  3. use Closure;
  4. use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
  5. use Opentalent\OtCore\Website\OtWebsiteRepository;
  6. use TYPO3\CMS\Core\Utility\GeneralUtility;
  7. use TYPO3\CMS\Extbase\Object\ObjectManager;
  8. use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
  9. /**
  10. * Viewhelper to retrieve the Uri of the root page of the current site
  11. * Call it in fluid templates with:
  12. *
  13. * {namespace ot=Opentalent\OtTemplating\ViewHelpers}
  14. *
  15. * {ot:rootPage.getUri()}
  16. *
  17. * @package Opentalent\OtTemplating\ViewHelpers
  18. */
  19. class GetUriViewHelper extends OtAbstractViewHelper
  20. {
  21. /**
  22. * -- This method is expected by Fluid --
  23. * Renders the content as html
  24. *
  25. * @param array $arguments
  26. * @param Closure $renderChildrenClosure
  27. * @param RenderingContextInterface $renderingContext
  28. * @return string
  29. */
  30. public static function renderStatic(
  31. array $arguments,
  32. Closure $renderChildrenClosure,
  33. RenderingContextInterface $renderingContext
  34. ) {
  35. $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
  36. return $pageRepository->getCurrentSiteRootUriFromFeGlobals();
  37. }
  38. }