* {domainGroup.title}
* * {skill.name}
*
* */ class SkillGroupingViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; protected $escapeOutput = false; public function initializeArguments() { $this->registerArgument('skills', 'array', 'An array of skills to group', false, []); $this->registerArgument('skillSet', 'array', 'The skills of this skill set will be grouped', false, []); $this->registerArgument('as', 'string', 'The name of the iteration variable', true); } public static function renderStatic( array $arguments, Closure $renderChildrenClosure, RenderingContextInterface $renderingContext ) { $skills = $arguments['skills']; $skillSet = $arguments['skillSet']; $as = $arguments['as']; if ($skillSet) { $groups = self::group($skillSet['skills']); } else { $groups = self::group($skills); } $templateVariableContainer = $renderingContext->getVariableProvider(); $output = ''; foreach ($groups['values'] as $groups => $group) { $templateVariableContainer->add($as, $group); $output .= $renderChildrenClosure(); $templateVariableContainer->remove($as); } return $output; } protected static function group(array $skills): array { $result = [ /* * [ * 'title' => 'Domain 1', * 'skills' => [...skills] * ] */ ]; // todo group skills based on domainTag|title return $result; } }