mirror of
https://github.com/SkillDisplay/TYPO3ContentElements.git
synced 2024-11-22 03:16:10 +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 Closure;
|
||||||
use Exception;
|
use SkillDisplay\PHPToolKit\Entity\Skill;
|
||||||
use SkillDisplay\PHPToolKit\Verification\Link;
|
use SkillDisplay\PHPToolKit\Entity\SkillSet;
|
||||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||||
|
@ -47,7 +47,7 @@ class SkillGroupingViewHelper extends AbstractViewHelper
|
||||||
public function initializeArguments()
|
public function initializeArguments()
|
||||||
{
|
{
|
||||||
$this->registerArgument('skills', 'array', 'An array of skills to group', false, []);
|
$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);
|
$this->registerArgument('as', 'string', 'The name of the iteration variable', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,19 +56,21 @@ class SkillGroupingViewHelper extends AbstractViewHelper
|
||||||
Closure $renderChildrenClosure,
|
Closure $renderChildrenClosure,
|
||||||
RenderingContextInterface $renderingContext
|
RenderingContextInterface $renderingContext
|
||||||
) {
|
) {
|
||||||
|
/** @var Skill[] $skills */
|
||||||
$skills = $arguments['skills'];
|
$skills = $arguments['skills'];
|
||||||
|
/** @var SkillSet $skillSet */
|
||||||
$skillSet = $arguments['skillSet'];
|
$skillSet = $arguments['skillSet'];
|
||||||
$as = $arguments['as'];
|
$as = $arguments['as'];
|
||||||
|
|
||||||
if ($skillSet) {
|
if ($skillSet) {
|
||||||
$groups = self::group($skillSet['skills']);
|
$groups = self::group($skillSet->getSkills());
|
||||||
} else {
|
} else {
|
||||||
$groups = self::group($skills);
|
$groups = self::group($skills);
|
||||||
}
|
}
|
||||||
|
|
||||||
$templateVariableContainer = $renderingContext->getVariableProvider();
|
$templateVariableContainer = $renderingContext->getVariableProvider();
|
||||||
$output = '';
|
$output = '';
|
||||||
foreach ($groups['values'] as $groups => $group) {
|
foreach ($groups as $group) {
|
||||||
$templateVariableContainer->add($as, $group);
|
$templateVariableContainer->add($as, $group);
|
||||||
$output .= $renderChildrenClosure();
|
$output .= $renderChildrenClosure();
|
||||||
$templateVariableContainer->remove($as);
|
$templateVariableContainer->remove($as);
|
||||||
|
@ -76,6 +78,10 @@ class SkillGroupingViewHelper extends AbstractViewHelper
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Skill[] $skills
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
protected static function group(array $skills): array
|
protected static function group(array $skills): array
|
||||||
{
|
{
|
||||||
$result = [
|
$result = [
|
||||||
|
|
Loading…
Reference in a new issue