CurrentViewHelper.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Opentalent\OtTemplating\ViewHelpers\Template;
  3. use Closure;
  4. use Opentalent\OtTemplating\Page\OtPageRepository;
  5. use TYPO3\CMS\Core\Utility\GeneralUtility;
  6. use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
  7. use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
  8. /**
  9. * Returns the name of the current template
  10. *
  11. * {namespace ot=Opentalent\OtTemplating\ViewHelpers}
  12. *
  13. * {ot:template.current()}
  14. *
  15. * @package Opentalent\OtTemplating\ViewHelpers\Template
  16. */
  17. class CurrentViewHelper extends AbstractViewHelper
  18. {
  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 int|null
  27. */
  28. public static function renderStatic(
  29. array $arguments,
  30. Closure $renderChildrenClosure,
  31. RenderingContextInterface $renderingContext
  32. ) {
  33. $pageRepository = GeneralUtility::makeInstance(OtPageRepository::class);
  34. return $pageRepository->getCurrentTemplate();
  35. }
  36. }