ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCtrlStructureHelper.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
30 protected array $ctrl_structure;
31
35 protected array $base_classes;
36
42 public function __construct(array $base_classes, array $ctrl_structure)
43 {
44 $this->ctrl_structure = $ctrl_structure;
45 $this->base_classes = $base_classes;
46 }
47
58 public function mapStructureReferences(): self
59 {
60 $this->ctrl_structure = (new ilCtrlStructureMapper(
61 $this->ctrl_structure
62 ))->getStructure();
63
64 return $this;
65 }
66
76 public function filterUnnecessaryEntries(): self
77 {
78 $this->ctrl_structure = array_filter(
79 $this->ctrl_structure,
80 function (array $value, string $key): bool {
81 // if the entry is not a baseclass and has no
82 // references, the entry will be removed.
83 return !(
84 !in_array($key, $this->base_classes, true) &&
87 );
88 },
89 ARRAY_FILTER_USE_BOTH
90 );
91
92 return $this;
93 }
94
99 public function getStructure(): array
100 {
102 }
103}
Class ilCtrlStructureHelper.
filterUnnecessaryEntries()
Fluent filter method that removes structure entries, whose parent- and child-references are empty.
__construct(array $base_classes, array $ctrl_structure)
ilCtrlStructureHelper Constructor
mapStructureReferences()
Fluent mapper method that adds vise-versa references for each entry in the current ctrl structure - e...
getStructure()
Returns the current ctrl structure.
Class ilCtrlStructureMapper.