| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace Opentalent\OtTemplating\ViewHelpers\Template;
- use Closure;
- use Opentalent\OtCore\Page\OtPageRepository;
- use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
- use Opentalent\OtTemplating\Templating\TemplateRepository;
- use TYPO3\CMS\Core\Utility\GeneralUtility;
- use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
- /**
- * Returns the value of the requested preference
- *
- * {namespace ot=Opentalent\OtTemplating\ViewHelpers}
- *
- * {ot:template.preference('themeColor')}
- *
- * @package Opentalent\OtTemplating\ViewHelpers\Template
- */
- class GetPreferenceViewHelper extends OtAbstractViewHelper
- {
- /**
- * -- This method is expected by Fluid --
- * Declares the viewhelper's parameters
- */
- public function initializeArguments()
- {
- $this->registerArgument(
- 'key',
- 'string',
- 'The name of the requested preference',
- true
- );
- }
- /**
- * -- This method is expected by Fluid --
- * Renders the content as html
- *
- * @param array $arguments
- * @param Closure $renderChildrenClosure
- * @param RenderingContextInterface $renderingContext
- * @return array
- */
- public static function renderStatic(
- array $arguments,
- Closure $renderChildrenClosure,
- RenderingContextInterface $renderingContext
- ) {
- $pageRepository = GeneralUtility::makeInstance(OtPageRepository::class);
- $rootUid = $pageRepository->getCurrentSiteRootPageId();
- $templateRepository = GeneralUtility::makeInstance(TemplateRepository::class);
- $preferences = $templateRepository->getTemplatePreferences($rootUid);
- $key = $arguments['key'];
- return $preferences[$key];
- }
- }
|