GetUriViewHelper.php 1.2 KB

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