CurrentViewHelper.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Opentalent\OtTemplating\ViewHelpers\Template;
  3. use Closure;
  4. use Opentalent\OtCore\Exception\NoSuchWebsiteException;
  5. use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
  6. use Opentalent\OtCore\Website\OtWebsiteRepository;
  7. use Opentalent\OtTemplating\Templating\TemplateRepository;
  8. use TYPO3\CMS\Core\Utility\GeneralUtility;
  9. use TYPO3\CMS\Extbase\Object\ObjectManager;
  10. use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
  11. /**
  12. * Returns the name of the current template
  13. *
  14. * {namespace ot=Opentalent\OtTemplating\ViewHelpers}
  15. *
  16. * {ot:template.current()}
  17. *
  18. * @package Opentalent\OtTemplating\ViewHelpers\Template
  19. */
  20. class CurrentViewHelper extends OtAbstractViewHelper
  21. {
  22. public function __construct(
  23. private readonly OtWebsiteRepository $otWebsiteRepository,
  24. private readonly TemplateRepository $templateRepository,
  25. ) {}
  26. /**
  27. * -- This method is expected by Fluid --
  28. * Renders the content as html
  29. *
  30. * @return string
  31. * @throws NoSuchWebsiteException
  32. */
  33. public function render(): string
  34. {
  35. $website = $this->otWebsiteRepository->getCurrentWebsiteFromFEGlobals();
  36. return $this->templateRepository->getTemplate($website);
  37. }
  38. }