GetWebsiteViewHelper.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Opentalent\OtTemplating\ViewHelpers\Request;
  3. use Closure;
  4. use Opentalent\OtCore\Exception\NoSuchWebsiteException;
  5. use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
  6. use Opentalent\OtCore\Website\OtWebsiteRepository;
  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 current Typo3 OtWebsite (FE only)
  12. *
  13. * {namespace ot=Opentalent\OtTemplating\ViewHelpers}
  14. *
  15. * {ot:request.getWebsite()}
  16. *
  17. * @package Opentalent\OtTemplating\ViewHelpers
  18. */
  19. class GetWebsiteViewHelper extends OtAbstractViewHelper {
  20. public function __construct(
  21. private readonly OtWebsiteRepository $otWebsiteRepository,
  22. ) {}
  23. /**
  24. * -- This method is expected by Fluid --
  25. * Renders the content as html
  26. *
  27. * @return array
  28. * @throws NoSuchWebsiteException
  29. */
  30. public function render(): array
  31. {
  32. return $this->otWebsiteRepository->getCurrentWebsiteFromFEGlobals();
  33. }
  34. }