* @author Timo Hund * */ class GroupViewHelper extends AbstractMeilisearchFrontendViewHelper { use CompileWithRenderStatic; /** * @var bool */ protected $escapeOutput = false; /** * Initializes the arguments */ public function initializeArguments() { parent::initializeArguments(); $this->registerArgument('facets', FacetCollection::class, 'The facets that should be filtered', true); $this->registerArgument('groupName', 'string', 'The groupName that should be shown', false, 'main'); } /** * @param array $arguments * @param \Closure $renderChildrenClosure * @param RenderingContextInterface $renderingContext * @return string */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) { /** @var $facets FacetCollection */ $facets = $arguments['facets']; $requiredGroup = isset($arguments['groupName']) ? $arguments['groupName'] : 'main'; $filtered = $facets->getByGroupName($requiredGroup); $templateVariableProvider = $renderingContext->getVariableProvider(); $templateVariableProvider->add('areaFacets', $filtered); $content = $renderChildrenClosure(); $templateVariableProvider->remove('areaFacets'); return $content; } }