19declare(strict_types=1);
64 if (!empty($this->ctrl_structure[$class_name][$key_ref_from])) {
65 $invalid_indices = [];
67 foreach ($this->ctrl_structure[$class_name][$key_ref_from] as
$index => $reference) {
68 $is_reference_available = isset($this->ctrl_structure[$reference]);
73 if ($is_reference_available && $is_reference_valid) {
75 if (!isset($this->ctrl_structure[$reference][$key_ref_to])) {
76 $this->ctrl_structure[$reference][$key_ref_to] = [];
80 if (!in_array($class_name, $this->ctrl_structure[$reference][$key_ref_to],
true)) {
81 $this->ctrl_structure[$reference][$key_ref_to][] = $class_name;
87 if (!$is_reference_available || !$is_reference_valid) {
88 $invalid_indices[] =
$index;
101 if (!empty($this->ctrl_structure)) {
102 foreach ($this->ctrl_structure as $class_name =>
$data) {
117 unset($this->ctrl_structure[$class_name]);
128 foreach ($invalid_indices as
$index) {
129 unset($this->ctrl_structure[$class_name][$key_ref_from][
$index]);
133 if (!empty($invalid_indices)) {
134 $this->ctrl_structure[$class_name][$key_ref_from] = array_values(
135 $this->ctrl_structure[$class_name][$key_ref_from]
155 if (!isset($this->ctrl_structure[
$index])) {
160 if (!is_array($this->ctrl_structure[
$index])) {
removeInvalidReferences(array $invalid_indices, string $class_name, string $key_ref_from)
isStructureEntryValid($index)
Helper function that returns whether an entry in the current structure is valid or not.
mapStructure()
Maps the current structures references.
addViseVersaMappingByClass(string $class_name, string $key_ref_from, string $key_ref_to)
If a class has referenced another one as child or parent, this method adds a vise-versa mapping if it...
__construct(array $ctrl_structure)
ilCtrlStructureMapper Constructor
getStructure()
Returns the current structure with mapped vise-versa references of each parent-child relation.