ILIAS  release_8 Revision v8.23
ilCtrlStructureHelper Class Reference

Class ilCtrlStructureHelper. More...

+ Collaboration diagram for ilCtrlStructureHelper:

Public Member Functions

 __construct (array $base_classes, array $ctrl_structure)
 ilCtrlStructureHelper Constructor More...
 
 mapStructureReferences ()
 Fluent mapper method that adds vise-versa references for each entry in the current ctrl structure - e.g. More...
 
 filterUnnecessaryEntries ()
 Fluent filter method that removes structure entries, whose parent- and child-references are empty. More...
 
 getStructure ()
 Returns the current ctrl structure. More...
 

Protected Attributes

array $ctrl_structure
 
array $base_classes
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCtrlStructureHelper::__construct ( array  $base_classes,
array  $ctrl_structure 
)

ilCtrlStructureHelper Constructor

Parameters
array$base_classes
array$ctrl_structure

Definition at line 28 of file class.ilCtrlStructureHelper.php.

References $base_classes, and $ctrl_structure.

29  {
30  $this->ctrl_structure = $ctrl_structure;
31  $this->base_classes = $base_classes;
32  }

Member Function Documentation

◆ filterUnnecessaryEntries()

ilCtrlStructureHelper::filterUnnecessaryEntries ( )

Fluent filter method that removes structure entries, whose parent- and child-references are empty.

That means these classes are not considered necessary GUI classes. Such structure entries can be safely removed, because if they have neither children nor parents, they will never be called unless they are a baseclass itself.

Returns
self

Definition at line 62 of file class.ilCtrlStructureHelper.php.

References ILIAS\LTI\ToolProvider\$key, ilCtrlStructureInterface\KEY_CLASS_CHILDREN, and ilCtrlStructureInterface\KEY_CLASS_PARENTS.

62  : 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  }
string $key
Consumer key/client ID value.
Definition: System.php:193

◆ getStructure()

ilCtrlStructureHelper::getStructure ( )

Returns the current ctrl structure.

Returns
array<string, mixed>

Definition at line 85 of file class.ilCtrlStructureHelper.php.

References $ctrl_structure.

Referenced by mapStructureReferences().

85  : array
86  {
87  return $this->ctrl_structure;
88  }
+ Here is the caller graph for this function:

◆ mapStructureReferences()

ilCtrlStructureHelper::mapStructureReferences ( )

Fluent mapper method that adds vise-versa references for each entry in the current ctrl structure - e.g.

if a class has several parent classes, this class is added as a child class to each parent, and vise-versa. This method doesn't necessarily need to be called, as it's performance heavy, but for example when reading the ctrl structure the mappings are wished to be complete.

Returns
self

Definition at line 44 of file class.ilCtrlStructureHelper.php.

References getStructure().

44  : self
45  {
46  $this->ctrl_structure = (new ilCtrlStructureMapper(
47  $this->ctrl_structure
48  ))->getStructure();
49 
50  return $this;
51  }
getStructure()
Returns the current ctrl structure.
Class ilCtrlStructureMapper.
+ Here is the call graph for this function:

Field Documentation

◆ $base_classes

array ilCtrlStructureHelper::$base_classes
protected

Definition at line 21 of file class.ilCtrlStructureHelper.php.

Referenced by __construct().

◆ $ctrl_structure

array ilCtrlStructureHelper::$ctrl_structure
protected

Definition at line 16 of file class.ilCtrlStructureHelper.php.

Referenced by __construct(), and getStructure().


The documentation for this class was generated from the following file: