ILIAS  release_8 Revision v8.24
class.ilCtrlStructureHelper.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/* Copyright (c) 2021 Thibeau Fuhrer <thf@studer-raimann.ch> Extended GPL, see docs/LICENSE */
6
12{
16 protected array $ctrl_structure;
17
21 protected array $base_classes;
22
28 public function __construct(array $base_classes, array $ctrl_structure)
29 {
30 $this->ctrl_structure = $ctrl_structure;
31 $this->base_classes = $base_classes;
32 }
33
44 public function mapStructureReferences(): self
45 {
46 $this->ctrl_structure = (new ilCtrlStructureMapper(
47 $this->ctrl_structure
48 ))->getStructure();
49
50 return $this;
51 }
52
62 public function filterUnnecessaryEntries(): self
63 {
64 $this->ctrl_structure = array_filter(
65 $this->ctrl_structure,
66 function (array $value, string $key): bool {
67 // if the entry is not a baseclass and has no
68 // references, the entry will be removed.
69 return !(
70 !in_array($key, $this->base_classes, true) &&
73 );
74 },
75 ARRAY_FILTER_USE_BOTH
76 );
77
78 return $this;
79 }
80
85 public function getStructure(): array
86 {
88 }
89}
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.
string $key
Consumer key/client ID value.
Definition: System.php:193