ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\MetaData\Structure\Dictionaries\Dictionary Class Reference
+ Inheritance diagram for ILIAS\MetaData\Structure\Dictionaries\Dictionary:
+ Collaboration diagram for ILIAS\MetaData\Structure\Dictionaries\Dictionary:

Public Member Functions

 __construct (PathFactoryInterface $path_factory, NavigatorFactoryInterface $navigator_factory, TagAssignmentInterface ... $tag_assignments)
 
 tagsForElement (BaseElementInterface $element)
 If possible, takes into account the index of elements when finding tags (beginning with 0). More...
 

Protected Member Functions

 getAllTagsForElement (PathInterface $path)
 
 doesIndexMatch (PathInterface $path, BaseElementInterface $element, TagInterface $tag)
 
 findIndexOfElement (PathInterface $path, ElementInterface $element)
 

Protected Attributes

PathFactoryInterface $path_factory
 
NavigatorFactoryInterface $navigator_factory
 

Private Attributes

array $tag_assignments = []
 

Detailed Description

Definition at line 32 of file Dictionary.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MetaData\Structure\Dictionaries\Dictionary::__construct ( PathFactoryInterface  $path_factory,
NavigatorFactoryInterface  $navigator_factory,
TagAssignmentInterface ...  $tag_assignments 
)

Definition at line 42 of file Dictionary.php.

46 {
47 $this->path_factory = $path_factory;
48 $this->navigator_factory = $navigator_factory;
49 foreach ($tag_assignments as $tag_assignment) {
50 $this->tag_assignments[$tag_assignment->path()->toString()][] = $tag_assignment->tag();
51 }
52 }
NavigatorFactoryInterface $navigator_factory
Definition: Dictionary.php:35

References ILIAS\MetaData\Structure\Dictionaries\Dictionary\$navigator_factory, ILIAS\MetaData\Structure\Dictionaries\Dictionary\$path_factory, and ILIAS\MetaData\Structure\Dictionaries\Dictionary\$tag_assignments.

Member Function Documentation

◆ doesIndexMatch()

ILIAS\MetaData\Structure\Dictionaries\Dictionary::doesIndexMatch ( PathInterface  $path,
BaseElementInterface  $element,
TagInterface  $tag 
)
protected

Definition at line 80 of file Dictionary.php.

84 : bool {
85 if (!($element instanceof ElementInterface)) {
86 return true;
87 }
88 if (!$tag->isRestrictedToIndices()) {
89 return true;
90 }
91 $index = $this->findIndexOfElement($path, $element);
92 if (in_array($index, iterator_to_array($tag->indices()), true)) {
93 return true;
94 }
95 return false;
96 }
findIndexOfElement(PathInterface $path, ElementInterface $element)
Definition: Dictionary.php:98
$path
Definition: ltiservices.php:30

Referenced by ILIAS\MetaData\Structure\Dictionaries\Dictionary\tagsForElement().

+ Here is the caller graph for this function:

◆ findIndexOfElement()

ILIAS\MetaData\Structure\Dictionaries\Dictionary::findIndexOfElement ( PathInterface  $path,
ElementInterface  $element 
)
protected

Definition at line 98 of file Dictionary.php.

101 : int {
102 $name = $element->getDefinition()->name();
103 $navigator = $this->navigator_factory->navigator($path, $element);
104 $index = 0;
105 foreach ($navigator->elementsAtFinalStep() as $sibling_element) {
106 if ($sibling_element === $element) {
107 return $index;
108 }
109 $index++;
110 }
111 throw new \ilMDStructureException('Invalid metadata set');
112 }

◆ getAllTagsForElement()

ILIAS\MetaData\Structure\Dictionaries\Dictionary::getAllTagsForElement ( PathInterface  $path)
protected
Returns
TagInterface[]

Definition at line 74 of file Dictionary.php.

76 : \Generator {
77 yield from $this->tag_assignments[$path->toString()] ?? [];
78 }

◆ tagsForElement()

ILIAS\MetaData\Structure\Dictionaries\Dictionary::tagsForElement ( BaseElementInterface  $element)

If possible, takes into account the index of elements when finding tags (beginning with 0).

Returns
TagInterface[]

Reimplemented in ILIAS\MetaData\Repository\Validation\Dictionary\LOMDictionary.

Definition at line 59 of file Dictionary.php.

61 : \Generator {
62 $path = $this->path_factory->toElement($element);
63 foreach ($this->getAllTagsForElement($path) as $tag) {
64 if (!$this->doesIndexMatch($path, $element, $tag)) {
65 continue;
66 }
67 yield $tag;
68 }
69 }
doesIndexMatch(PathInterface $path, BaseElementInterface $element, TagInterface $tag)
Definition: Dictionary.php:80

References $path, and ILIAS\MetaData\Structure\Dictionaries\Dictionary\doesIndexMatch().

+ Here is the call graph for this function:

Field Documentation

◆ $navigator_factory

NavigatorFactoryInterface ILIAS\MetaData\Structure\Dictionaries\Dictionary::$navigator_factory
protected

◆ $path_factory

PathFactoryInterface ILIAS\MetaData\Structure\Dictionaries\Dictionary::$path_factory
protected

◆ $tag_assignments

array ILIAS\MetaData\Structure\Dictionaries\Dictionary::$tag_assignments = []
private

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