ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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...
 
 getMDID ()
 
 getDefinition ()
 Defining properties of the metadata element. More...
 
 getSubElements ()
 
 getSuperElement ()
 
 isRoot ()
 

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.

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

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

+ 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.

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 }
setSuperElement(?BaseElement $super_element)

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

+ 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.

78 : void
79 {
80 $sub_element->setSuperElement($this);
81 $this->sub_elements[] = $sub_element;
82 }

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

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefinition()

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

◆ getMDID()

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

◆ getSubElements()

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

◆ getSuperElement()

◆ isRoot()

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

Implements ILIAS\MetaData\Elements\Base\BaseElementInterface.

Definition at line 117 of file BaseElement.php.

117 : bool
118 {
119 return $this->getMDID() === NoID::ROOT;
120 }

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

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

+ 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.

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 }

◆ setSuperElement()

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

Definition at line 107 of file BaseElement.php.

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 }

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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $definition

◆ $md_id

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

◆ $sub_elements

◆ $super_element

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

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