GetUriViewHelper.php 1.3 KB

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