ILIAS  trunk Revision v11.0_alpha-1862-g4e205cb56d4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\MetaData\Elements\Base\BaseElement Class Reference
+ Inheritance diagram for ILIAS\MetaData\Elements\Base\BaseElement:
+ Collaboration diagram for ILIAS\MetaData\Elements\Base\BaseElement:

Public Member Functions

 __construct (int|NoID $md_id, DefinitionInterface $definition, BaseElement ... $sub_elements)
 
 __clone ()
 
 getMDID ()
 
 getSubElements ()
 
 getSuperElement ()
 
 isRoot ()
 
 getDefinition ()
 Defining properties of the metadata element. More...
 

Protected Member Functions

 addSubElement (BaseElement $sub_element)
 
 orderSubElements (string ... $names_in_order)
 
 setSuperElement (?BaseElement $super_element)
 

Private Attributes

array $sub_elements = []
 
BaseElement $super_element = null
 
DefinitionInterface $definition
 
int NoID $md_id
 

Detailed Description

Definition at line 27 of file BaseElement.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MetaData\Elements\Base\BaseElement::__construct ( int|NoID  $md_id,
DefinitionInterface  $definition,
BaseElement ...  $sub_elements 
)

Definition at line 37 of file BaseElement.php.

References ILIAS\MetaData\Elements\Base\BaseElement\$definition, ILIAS\MetaData\Elements\Base\BaseElement\$md_id, and ILIAS\MetaData\Elements\Base\BaseElement\addSubElement().

41  {
42  foreach ($sub_elements as $sub_element) {
43  $this->addSubElement($sub_element);
44  }
45  $this->definition = $definition;
46  $this->md_id = $md_id;
47  }
addSubElement(BaseElement $sub_element)
Definition: BaseElement.php:78
+ Here is the call graph for this function:

Member Function Documentation

◆ __clone()

ILIAS\MetaData\Elements\Base\BaseElement::__clone ( )

Definition at line 49 of file BaseElement.php.

References null, and ILIAS\MetaData\Elements\Base\BaseElement\setSuperElement().

50  {
51  if (!is_null($this->super_element)) {
52  $this->setSuperElement(null);
53  }
54  $map = function (BaseElement $arg) {
55  $arg = clone $arg;
56  $arg->setSuperElement($this);
57  return $arg;
58  };
59  $this->sub_elements = array_map(
60  $map,
61  $this->sub_elements
62  );
63  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setSuperElement(?BaseElement $super_element)
+ Here is the call graph for this function:

◆ addSubElement()

ILIAS\MetaData\Elements\Base\BaseElement::addSubElement ( BaseElement  $sub_element)
protected

Definition at line 78 of file BaseElement.php.

References ILIAS\MetaData\Elements\Base\BaseElement\setSuperElement().

Referenced by ILIAS\MetaData\Elements\Base\BaseElement\__construct(), ILIAS\MetaData\Elements\Element\addScaffoldsToSubElements(), and ILIAS\MetaData\Elements\Element\addScaffoldToSubElements().

78  : void
79  {
80  $sub_element->setSuperElement($this);
81  $this->sub_elements[] = $sub_element;
82  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefinition()

ILIAS\MetaData\Elements\Base\BaseElement::getDefinition ( )

Defining properties of the metadata element.

Implements ILIAS\MetaData\Elements\Base\BaseElementInterface.

Definition at line 122 of file BaseElement.php.

References ILIAS\MetaData\Elements\Base\BaseElement\$definition.

122  : DefinitionInterface
123  {
124  return $this->definition;
125  }

◆ getMDID()

ILIAS\MetaData\Elements\Base\BaseElement::getMDID ( )

◆ getSubElements()

ILIAS\MetaData\Elements\Base\BaseElement::getSubElements ( )

◆ getSuperElement()

ILIAS\MetaData\Elements\Base\BaseElement::getSuperElement ( )

Implements ILIAS\MetaData\Elements\Base\BaseElementInterface.

Definition at line 102 of file BaseElement.php.

References ILIAS\MetaData\Elements\Base\BaseElement\$super_element.

102  : ?BaseElement
103  {
104  return $this->super_element;
105  }

◆ isRoot()

ILIAS\MetaData\Elements\Base\BaseElement::isRoot ( )

Implements ILIAS\MetaData\Elements\Base\BaseElementInterface.

Definition at line 117 of file BaseElement.php.

References ILIAS\MetaData\Elements\Base\BaseElement\getMDID().

Referenced by ILIAS\MetaData\Elements\Base\BaseElement\setSuperElement().

117  : bool
118  {
119  return $this->getMDID() === NoID::ROOT;
120  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ orderSubElements()

ILIAS\MetaData\Elements\Base\BaseElement::orderSubElements ( string ...  $names_in_order)
protected

Definition at line 84 of file BaseElement.php.

Referenced by ILIAS\MetaData\Elements\Element\addScaffoldsToSubElements(), and ILIAS\MetaData\Elements\Element\addScaffoldToSubElements().

84  : void
85  {
86  $sub_elements_by_name = [];
87  foreach ($this->sub_elements as $sub_element) {
88  $sub_elements_by_name[$sub_element->getDefinition()->name()][] = $sub_element;
89  }
90 
91  $reordered_sub_elements = [];
92  foreach ($names_in_order as $name) {
93  $reordered_sub_elements = array_merge(
94  $reordered_sub_elements,
95  $sub_elements_by_name[$name] ?? []
96  );
97  }
98 
99  $this->sub_elements = $reordered_sub_elements;
100  }
+ Here is the caller graph for this function:

◆ setSuperElement()

ILIAS\MetaData\Elements\Base\BaseElement::setSuperElement ( ?BaseElement  $super_element)
protected

Definition at line 107 of file BaseElement.php.

References ILIAS\MetaData\Elements\Base\BaseElement\$super_element, and ILIAS\MetaData\Elements\Base\BaseElement\isRoot().

Referenced by ILIAS\MetaData\Elements\Base\BaseElement\__clone(), and ILIAS\MetaData\Elements\Base\BaseElement\addSubElement().

107  : void
108  {
109  if ($this->isRoot()) {
110  throw new \ilMDElementsException(
111  'Metadata root can not have a super element.'
112  );
113  }
114  $this->super_element = $super_element;
115  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $definition

DefinitionInterface ILIAS\MetaData\Elements\Base\BaseElement::$definition
private

◆ $md_id

int NoID ILIAS\MetaData\Elements\Base\BaseElement::$md_id
private

◆ $sub_elements

array ILIAS\MetaData\Elements\Base\BaseElement::$sub_elements = []
private

◆ $super_element

BaseElement ILIAS\MetaData\Elements\Base\BaseElement::$super_element = null
private

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