ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
PropertiesFetcher.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26
28{
32
33 public function __construct(
37 ) {
38 $this->dictionary = $dictionary;
39 $this->presenter = $presenter;
40 $this->data_finder = $data_finder;
41 }
42
46 public function getPropertiesByPreview(
47 ElementInterface $element
48 ): \Generator {
49 $sub_els = [];
50 foreach ($element->getSubElements() as $sub) {
51 if ($sub->isScaffold()) {
52 continue;
53 }
54 $tag = $this->dictionary->tagForElement($sub);
55 $label = $this->presenter->elements()->nameWithRepresentation(
56 $tag?->isCollected() && $tag?->isLastInTree(),
57 $sub
58 );
59 $sub_els[$label][] = $sub;
60 }
61 foreach ($sub_els as $label => $els) {
62 $value = $this->presenter->elements()->preview(
63 ...$els
64 );
65 yield $label => $value;
66 }
67 }
68
72 public function getPropertiesByData(
73 ElementInterface $element
74 ): \Generator {
75 $data_els = $this->data_finder->getDataCarryingElements(
76 $element,
77 true
78 );
79 foreach ($data_els as $data_el) {
80 if ($data_el->isScaffold()) {
81 continue;
82 }
83 $title = $this->presenter->elements()->nameWithParents(
84 $data_el,
85 $element
86 );
87 $value = $this->presenter->data()->dataValue($data_el->getData());
88 yield $title => $value;
89 }
90 }
91}
__construct(DictionaryInterface $dictionary, PresenterInterface $presenter, DataFinder $data_finder)
return true