From 901b7ab2be119d3ce5e4983caf5ccf2a30cdb1ac Mon Sep 17 00:00:00 2001 From: Markus Klein Date: Fri, 7 Jul 2023 09:28:13 +0200 Subject: [PATCH] [FEATURE] VH to group skills by domain --- .../ViewHelpers/SkillGroupingViewHelper.php | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Classes/ViewHelpers/SkillGroupingViewHelper.php diff --git a/Classes/ViewHelpers/SkillGroupingViewHelper.php b/Classes/ViewHelpers/SkillGroupingViewHelper.php new file mode 100644 index 0000000..884903e --- /dev/null +++ b/Classes/ViewHelpers/SkillGroupingViewHelper.php @@ -0,0 +1,93 @@ + + * {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; + } +}