ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
DataFinder.php
Go to the documentation of this file.
1<?php
2
19declare(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,
65 $this->getDataElementsInSubElements(
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
getDataCarryingElements(ElementInterface $start_element, bool $skip_vocab_source=false)
Definition: DataFinder.php:31
if(!file_exists('../ilias.ini.php'))