| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace Opentalent\OtTemplating\ViewHelpers\Template;
- use Closure;
- use Opentalent\OtCore\ViewHelpers\OtAbstractViewHelper;
- use Opentalent\OtCore\Website\OtWebsiteRepository;
- use Opentalent\OtTemplating\Templating\TemplateRepository;
- use TYPO3\CMS\Core\Utility\GeneralUtility;
- use TYPO3\CMS\Extbase\Object\ObjectManager;
- 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(ObjectManager::class)->get(OtWebsiteRepository::class);
- $website = $pageRepository->getCurrentWebsiteFromFEGlobals();
- $templateRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(TemplateRepository::class);
- $preferences = $templateRepository->getTemplatePreferences($website);
- $key = $arguments['key'];
- return $preferences[$key];
- }
- }
|