ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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='')
 
 unmark ()
 Removes markers from this element, and recursively from all sub-elements. More...
 
 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\GlobalScreen\Provider\__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. Scaffolds are added such that the order of elements as suggested by the structure is preserved.

Implements ILIAS\MetaData\Elements\Scaffolds\ScaffoldableInterface.

Definition at line 128 of file Element.php.

References ILIAS\MetaData\Elements\Base\BaseElement\addSubElement(), ILIAS\MetaData\Manipulator\ScaffoldProvider\ScaffoldProviderInterface\getPossibleSubElementNamesForElementInOrder(), ILIAS\MetaData\Manipulator\ScaffoldProvider\ScaffoldProviderInterface\getScaffoldsForElement(), null, and ILIAS\MetaData\Elements\Base\BaseElement\orderSubElements().

130  : void {
131  foreach ($scaffold_provider->getScaffoldsForElement($this) as $scaffold) {
132  if ($scaffold->getSubElements()->current() !== null) {
133  throw new \ilMDElementsException('Can only add scaffolds with no sub-elements.');
134  }
135  $this->addSubElement($scaffold);
136  $this->orderSubElements(...$scaffold_provider->getPossibleSubElementNamesForElementInOrder($this));
137  }
138  }
orderSubElements(string ... $names_in_order)
Definition: BaseElement.php:84
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
addSubElement(BaseElement $sub_element)
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.

Scaffolds are added such that the order of elements as suggested by the structure is preserved.

Returns
ElementInterface[]

Implements ILIAS\MetaData\Elements\Scaffolds\ScaffoldableInterface.

Definition at line 140 of file Element.php.

References ILIAS\MetaData\Elements\Base\BaseElement\addSubElement(), ILIAS\MetaData\Manipulator\ScaffoldProvider\ScaffoldProviderInterface\getPossibleSubElementNamesForElementInOrder(), ILIAS\MetaData\Manipulator\ScaffoldProvider\ScaffoldProviderInterface\getScaffoldsForElement(), null, and ILIAS\MetaData\Elements\Base\BaseElement\orderSubElements().

143  : ?ElementInterface {
144  foreach ($scaffold_provider->getScaffoldsForElement($this) as $scaffold) {
145  if (strtolower($scaffold->getDefinition()->name()) === strtolower($name)) {
146  if ($scaffold->getSubElements()->current() !== null) {
147  throw new \ilMDElementsException('Can only add scaffolds with no sub-elements.');
148  }
149  $this->addSubElement($scaffold);
150  $this->orderSubElements(...$scaffold_provider->getPossibleSubElementNamesForElementInOrder($this));
151  return $scaffold;
152  }
153  }
154  return null;
155  }
orderSubElements(string ... $names_in_order)
Definition: BaseElement.php:84
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
addSubElement(BaseElement $sub_element)
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.

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

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  }
+ Here is the caller graph for this function:

◆ 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:123
+ Here is the call graph for this function:

◆ setMarker()

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

Definition at line 123 of file Element.php.

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

Referenced by ILIAS\MetaData\Elements\Element\mark(), and ILIAS\MetaData\Elements\Element\unmark().

123  : void
124  {
125  $this->marker = $marker;
126  }
+ Here is the caller graph for this function:

◆ unmark()

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

Removes markers from this element, and recursively from all sub-elements.

Implements ILIAS\MetaData\Elements\Markers\MarkableInterface.

Definition at line 115 of file Element.php.

References ILIAS\MetaData\Elements\Element\getSubElements(), null, and ILIAS\MetaData\Elements\Element\setMarker().

115  : void
116  {
117  $this->setMarker(null);
118  foreach ($this->getSubElements() as $sub_element) {
119  $sub_element->unmark();
120  }
121  }
setMarker(?MarkerInterface $marker)
Definition: Element.php:123
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call 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: