GetPreferencesViewHelper.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Opentalent\OtTemplating\ViewHelpers\Template;
  3. use Closure;
  4. use Opentalent\OtTemplating\Utilities\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 recorded preferences
  10. *
  11. * {namespace ot=Opentalent\OtTemplating\ViewHelpers}
  12. *
  13. * {ot:template.preferences()}
  14. *
  15. * @package Opentalent\OtTemplating\ViewHelpers\Template
  16. */
  17. class PreferencesViewHelper 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 array
  27. */
  28. public static function renderStatic(
  29. array $arguments,
  30. Closure $renderChildrenClosure,
  31. RenderingContextInterface $renderingContext
  32. ) {
  33. if (TYPO3_MODE == 'FE') {
  34. $pageUid = (int) $GLOBALS['TSFE']->id;
  35. } else {
  36. $pageUid = (int) GeneralUtility::_GP('id');
  37. }
  38. $pageRepository = new OtPageRepository();
  39. return $pageRepository->getTemplatePreferences($pageUid);
  40. }
  41. }