Conditions | 5 |
Paths | 6 |
Total Lines | 21 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
19 | private function setChannelRelations($channels) |
||
20 | { |
||
21 | $indexedChannels = []; |
||
22 | |||
23 | /** @var Channel $channel */ |
||
24 | foreach ($channels as $channel) { |
||
25 | $indexedChannels[$channel->getId()] = $channel; |
||
26 | } |
||
27 | |||
28 | foreach ($indexedChannels as $channel) { |
||
29 | $parentId = $channel->getParentId(); |
||
30 | if ($parentId && array_key_exists($parentId, $indexedChannels)) { |
||
31 | /** @var Channel $parent */ |
||
32 | $parent = $indexedChannels[$parentId]; |
||
33 | $channel->setParent($parent); |
||
34 | $parent->addChild($channel); |
||
35 | } |
||
36 | } |
||
37 | |||
38 | return array_values($indexedChannels); |
||
39 | } |
||
40 | } |
||
41 |