GetWebsiteViewHelper.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Opentalent\OtTemplating\ViewHelpers\Request;
  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. * Returns the current Typo3 OtWebsite (FE only)
  11. *
  12. * {namespace ot=Opentalent\OtTemplating\ViewHelpers}
  13. *
  14. * {ot:request.getWebsite()}
  15. *
  16. * @package Opentalent\OtTemplating\ViewHelpers
  17. */
  18. class GetWebsiteViewHelper extends OtAbstractViewHelper {
  19. /**
  20. * -- This method is expected by Fluid --
  21. * Renders the content as html
  22. *
  23. * @param array $arguments
  24. * @param Closure $renderChildrenClosure
  25. * @param RenderingContextInterface $renderingContext
  26. * @return string|null
  27. */
  28. public static function renderStatic(
  29. array $arguments,
  30. Closure $renderChildrenClosure,
  31. RenderingContextInterface $renderingContext
  32. ) {
  33. $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
  34. return $pageRepository->getCurrentWebsiteFromFEGlobals();
  35. }
  36. }