mirror of
https://github.com/SkillDisplay/TYPO3ContentElements.git
synced 2024-11-22 03:16:10 +01:00
Merge remote-tracking branch 'origin/fluid-template-skill-grouping'
This commit is contained in:
commit
b6e99f84ed
1 changed files with 17 additions and 8 deletions
|
@ -84,21 +84,30 @@ class SkillGroupingViewHelper extends AbstractViewHelper
|
||||||
*/
|
*/
|
||||||
protected static function group(array $skills): array
|
protected static function group(array $skills): array
|
||||||
{
|
{
|
||||||
$domainTags = [];
|
$domainTagsWithId = [];
|
||||||
foreach ($skills as $skill) {
|
foreach ($skills as $skill) {
|
||||||
$domainTags[] = isset($skill->toArray()['domainTag']) ? $skill->toArray()['domainTag']['title'] : "none";
|
if (!isset($skill->toArray()['domainTag'])) {
|
||||||
|
$domainTagsWithId[] = [
|
||||||
|
'uid' => 0,
|
||||||
|
'title' => 'none'
|
||||||
|
];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
$domainTags = array_unique($domainTags);
|
$domainTagsWithId[] = $skill->toArray()['domainTag'];
|
||||||
|
}
|
||||||
|
//remove items with duplicate title
|
||||||
|
$domainTagsWithId = array_map('unserialize', array_unique(array_map('serialize', $domainTagsWithId)));
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($domainTags as $domainTag) {
|
foreach ($domainTagsWithId as $domainTag) {
|
||||||
$result[] = [
|
$result[] = [
|
||||||
'title' => $domainTag,
|
'title' => $domainTag['title'],
|
||||||
'skills' => array_filter($skills, function (Skill $skill) use ($domainTag) {
|
'uid' => $domainTag['uid'],
|
||||||
|
'skills' => array_filter($skills, function ($skill) use ($domainTag) {
|
||||||
if (!isset($skill->toArray()['domainTag'])) {
|
if (!isset($skill->toArray()['domainTag'])) {
|
||||||
return $domainTag === "none";
|
return $domainTag['title'] === 'none';
|
||||||
}
|
}
|
||||||
return $skill->toArray()['domainTag']['title'] === $domainTag;
|
return $skill->toArray()['domainTag']['title'] === $domainTag['title'];
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue