mirror of
https://github.com/SkillDisplay/TYPO3ContentElements.git
synced 2024-12-22 06:16:09 +01:00
[TASK] Use types from SD PHP API
This commit is contained in:
parent
901b7ab2be
commit
ffde64c04b
1 changed files with 11 additions and 5 deletions
|
@ -22,8 +22,8 @@ namespace SkillDisplay\SkilldisplayContent\ViewHelpers;
|
|||
*/
|
||||
|
||||
use Closure;
|
||||
use Exception;
|
||||
use SkillDisplay\PHPToolKit\Verification\Link;
|
||||
use SkillDisplay\PHPToolKit\Entity\Skill;
|
||||
use SkillDisplay\PHPToolKit\Entity\SkillSet;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
@ -47,7 +47,7 @@ class SkillGroupingViewHelper extends AbstractViewHelper
|
|||
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('skillSet', SkillSet::class, 'The skills of this skill set will be grouped', false, []);
|
||||
$this->registerArgument('as', 'string', 'The name of the iteration variable', true);
|
||||
}
|
||||
|
||||
|
@ -56,19 +56,21 @@ class SkillGroupingViewHelper extends AbstractViewHelper
|
|||
Closure $renderChildrenClosure,
|
||||
RenderingContextInterface $renderingContext
|
||||
) {
|
||||
/** @var Skill[] $skills */
|
||||
$skills = $arguments['skills'];
|
||||
/** @var SkillSet $skillSet */
|
||||
$skillSet = $arguments['skillSet'];
|
||||
$as = $arguments['as'];
|
||||
|
||||
if ($skillSet) {
|
||||
$groups = self::group($skillSet['skills']);
|
||||
$groups = self::group($skillSet->getSkills());
|
||||
} else {
|
||||
$groups = self::group($skills);
|
||||
}
|
||||
|
||||
$templateVariableContainer = $renderingContext->getVariableProvider();
|
||||
$output = '';
|
||||
foreach ($groups['values'] as $groups => $group) {
|
||||
foreach ($groups as $group) {
|
||||
$templateVariableContainer->add($as, $group);
|
||||
$output .= $renderChildrenClosure();
|
||||
$templateVariableContainer->remove($as);
|
||||
|
@ -76,6 +78,10 @@ class SkillGroupingViewHelper extends AbstractViewHelper
|
|||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Skill[] $skills
|
||||
* @return array
|
||||
*/
|
||||
protected static function group(array $skills): array
|
||||
{
|
||||
$result = [
|
||||
|
|
Loading…
Reference in a new issue