ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
DataFinder.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
25 
27 {
31  public function getDataCarryingElements(
32  ElementInterface $start_element,
33  bool $skip_vocab_source = false
34  ): \Generator {
35  $elements = $this->getDataElementsInSubElements(
36  $start_element,
37  $skip_vocab_source,
38  0
39  );
40  yield from $elements;
41  }
42 
46  protected function getDataElementsInSubElements(
47  ElementInterface $current_element,
48  bool $skip_vocab_source,
49  int $depth
50  ): array {
51  if ($depth > 20) {
52  throw new \ilMDEditorException('LOM Structure is nested to deep.');
53  }
54  $elements = [];
55  $type = $current_element->getDefinition()->dataType();
56  if (
57  $type !== Type::NULL &&
58  !($skip_vocab_source && $type === Type::VOCAB_SOURCE)
59  ) {
60  $elements[] = $current_element;
61  }
62  foreach ($current_element->getSubElements() as $sub) {
63  $elements = array_merge(
64  $elements,
66  $sub,
67  $skip_vocab_source,
68  $depth + 1
69  )
70  );
71  }
72  return $elements;
73  }
74 }
getDataElementsInSubElements(ElementInterface $current_element, bool $skip_vocab_source, int $depth)
Definition: DataFinder.php:46
getDefinition()
Defining properties of the metadata element.
getDataCarryingElements(ElementInterface $start_element, bool $skip_vocab_source=false)
Definition: DataFinder.php:31