ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ILIAS\MetaData\Elements\Element Class Reference
+ Inheritance diagram for ILIAS\MetaData\Elements\Element:
+ Collaboration diagram for ILIAS\MetaData\Elements\Element:

Public Member Functions

 __construct (NoID|int $md_id, DefinitionInterface $definition, DataInterface $data, Element ... $sub_elements)
 
 getData ()
 
 isScaffold ()
 
 getSuperElement ()
 
 getSubElements ()
 
 isMarked ()
 Elements can be marked to be created, updated or deleted. More...
 
 getMarker ()
 
 mark (MarkerFactoryInterface $factory, Action $action, string $data_value='')
 
 addScaffoldsToSubElements (ScaffoldProviderInterface $scaffold_provider)
 Scaffolds are used to mark where elements could potentially be created. More...
 
 addScaffoldToSubElements (ScaffoldProviderInterface $scaffold_provider, string $name)
 If possible, adds a scaffold with the given name to this element's sub-elements, and returns it. More...
 

Protected Member Functions

 setMarker (?MarkerInterface $marker)
 

Private Attributes

MarkerInterface $marker = null
 
DataInterface $data
 

Detailed Description

Definition at line 34 of file Element.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MetaData\Elements\Element::__construct ( NoID|int  $md_id,
DefinitionInterface  $definition,
DataInterface  $data,
Element ...  $sub_elements 
)

Definition at line 39 of file Element.php.

References ILIAS\MetaData\Elements\Element\$data, and ILIAS\MetaData\Repository\Validation\Data\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ addScaffoldsToSubElements()

ILIAS\MetaData\Elements\Element::addScaffoldsToSubElements ( ScaffoldProviderInterface  $scaffold_provider)

Scaffolds are used to mark where elements could potentially be created.

Adds all possible scaffolds to this element's sub-elements.

Implements ILIAS\MetaData\Elements\Scaffolds\ScaffoldableInterface.

Definition at line 120 of file Element.php.

References ILIAS\MetaData\Elements\Base\BaseElement\addSubElement(), and ILIAS\MetaData\Repository\Utilities\ScaffoldProviderInterface\getScaffoldsForElement().

122  : void {
123  foreach ($scaffold_provider->getScaffoldsForElement($this) as $insert_before => $scaffold) {
124  if ($scaffold->getSubElements()->current() !== null) {
125  throw new \ilMDElementsException('Can only add scaffolds with no sub-elements.');
126  }
127  $this->addSubElement($scaffold, $insert_before);
128  }
129  }
addSubElement(BaseElement $sub_element, string $insert_before='')
Definition: BaseElement.php:78
+ Here is the call graph for this function:

◆ addScaffoldToSubElements()

ILIAS\MetaData\Elements\Element::addScaffoldToSubElements ( ScaffoldProviderInterface  $scaffold_provider,
string  $name 
)

If possible, adds a scaffold with the given name to this element's sub-elements, and returns it.

Returns
ElementInterface[]

Implements ILIAS\MetaData\Elements\Scaffolds\ScaffoldableInterface.

Definition at line 131 of file Element.php.

References ILIAS\MetaData\Elements\Base\BaseElement\addSubElement(), and ILIAS\MetaData\Repository\Utilities\ScaffoldProviderInterface\getScaffoldsForElement().

134  : ?ElementInterface {
135  foreach ($scaffold_provider->getScaffoldsForElement($this) as $insert_before => $scaffold) {
136  if (strtolower($scaffold->getDefinition()->name()) === strtolower($name)) {
137  if ($scaffold->getSubElements()->current() !== null) {
138  throw new \ilMDElementsException('Can only add scaffolds with no sub-elements.');
139  }
140  $this->addSubElement($scaffold, $insert_before);
141  return $scaffold;
142  }
143  }
144  return null;
145  }
addSubElement(BaseElement $sub_element, string $insert_before='')
Definition: BaseElement.php:78
+ Here is the call graph for this function:

◆ getData()

ILIAS\MetaData\Elements\Element::getData ( )

Implements ILIAS\MetaData\Elements\ElementInterface.

Definition at line 49 of file Element.php.

References ILIAS\MetaData\Elements\Element\$data.

49  : DataInterface
50  {
51  return $this->data;
52  }

◆ getMarker()

ILIAS\MetaData\Elements\Element::getMarker ( )

Implements ILIAS\MetaData\Elements\Markers\MarkableInterface.

Definition at line 90 of file Element.php.

References ILIAS\MetaData\Elements\Element\$marker.

90  : ?MarkerInterface
91  {
92  return $this->marker;
93  }

◆ getSubElements()

ILIAS\MetaData\Elements\Element::getSubElements ( )
Returns
Element[]

Implements ILIAS\MetaData\Elements\ElementInterface.

Definition at line 73 of file Element.php.

73  : \Generator
74  {
75  foreach (parent::getSubElements() as $sub_element) {
76  if (!($sub_element instanceof Element)) {
77  throw new \ilMDElementsException(
78  'Metadata element has invalid sub-element.'
79  );
80  }
81  yield $sub_element;
82  }
83  }

◆ getSuperElement()

ILIAS\MetaData\Elements\Element::getSuperElement ( )

Implements ILIAS\MetaData\Elements\ElementInterface.

Definition at line 59 of file Element.php.

Referenced by ILIAS\MetaData\Elements\Element\mark().

59  : ?Element
60  {
61  $super = parent::getSuperElement();
62  if (!isset($super) || ($super instanceof Element)) {
63  return $super;
64  }
65  throw new \ilMDElementsException(
66  'Metadata element has invalid super-element.'
67  );
68  }
+ Here is the caller graph for this function:

◆ isMarked()

ILIAS\MetaData\Elements\Element::isMarked ( )

Elements can be marked to be created, updated or deleted.

Implements ILIAS\MetaData\Elements\Markers\MarkableInterface.

Definition at line 85 of file Element.php.

85  : bool
86  {
87  return isset($this->marker);
88  }

◆ isScaffold()

ILIAS\MetaData\Elements\Element::isScaffold ( )

Implements ILIAS\MetaData\Elements\ElementInterface.

Definition at line 54 of file Element.php.

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

54  : bool
55  {
56  return $this->getMDID() === NoID::SCAFFOLD;
57  }
+ Here is the call graph for this function:

◆ mark()

ILIAS\MetaData\Elements\Element::mark ( MarkerFactoryInterface  $factory,
Action  $action,
string  $data_value = '' 
)

Definition at line 95 of file Element.php.

References ILIAS\MetaData\Elements\Element\getSuperElement(), ILIAS\MetaData\Elements\Markers\MarkerFactoryInterface\marker(), and ILIAS\MetaData\Elements\Element\setMarker().

99  : void {
100  $this->setMarker($factory->marker($action, $data_value));
101  $curr_element = $this->getSuperElement();
102  while ($curr_element) {
103  if ($curr_element->isMarked()) {
104  return;
105  }
106  $trail_action = Action::NEUTRAL;
107  if ($curr_element->isScaffold() && $action === Action::CREATE_OR_UPDATE) {
108  $trail_action = Action::CREATE_OR_UPDATE;
109  }
110  $curr_element->setMarker($factory->marker($trail_action));
111  $curr_element = $curr_element->getSuperElement();
112  }
113  }
setMarker(?MarkerInterface $marker)
Definition: Element.php:115
+ Here is the call graph for this function:

◆ setMarker()

ILIAS\MetaData\Elements\Element::setMarker ( ?MarkerInterface  $marker)
protected

Definition at line 115 of file Element.php.

References ILIAS\MetaData\Elements\Element\$marker.

Referenced by ILIAS\MetaData\Elements\Element\mark().

115  : void
116  {
117  $this->marker = $marker;
118  }
+ Here is the caller graph for this function:

Field Documentation

◆ $data

DataInterface ILIAS\MetaData\Elements\Element::$data
private

◆ $marker

MarkerInterface ILIAS\MetaData\Elements\Element::$marker = null
private

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