CurrentViewHelper.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Opentalent\OtTemplating\ViewHelpers\Template;
  3. use Closure;
  4. use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
  5. use Opentalent\OtCore\Website\OtWebsiteRepository;
  6. use Opentalent\OtTemplating\Templating\TemplateRepository;
  7. use TYPO3\CMS\Core\Utility\GeneralUtility;
  8. use TYPO3\CMS\Extbase\Object\ObjectManager;
  9. use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
  10. /**
  11. * Returns the name of the current template
  12. *
  13. * {namespace ot=Opentalent\OtTemplating\ViewHelpers}
  14. *
  15. * {ot:template.current()}
  16. *
  17. * @package Opentalent\OtTemplating\ViewHelpers\Template
  18. */
  19. class CurrentViewHelper 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 int|null
  29. */
  30. public static function renderStatic(
  31. array $arguments,
  32. Closure $renderChildrenClosure,
  33. RenderingContextInterface $renderingContext
  34. ) {
  35. $website = $GLOBALS['TYPO3_REQUEST']->getAttribute('ot_website');
  36. $templateRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(TemplateRepository::class);
  37. return $templateRepository->getTemplate($website);
  38. }
  39. }