CurrentViewHelper.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. $pageRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OtWebsiteRepository::class);
  36. $website = $pageRepository->getCurrentWebsiteFromFEGlobals();
  37. $templateRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(TemplateRepository::class);
  38. return $templateRepository->getTemplate($website);
  39. }
  40. }