ILIAS  trunk Revision v11.0_alpha-1838-g59fc79e306b
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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

 getAssignmentsForElement (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 
)

Member Function Documentation

◆ doesIndexMatch()

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

Definition at line 83 of file Dictionary.php.

References ILIAS\MetaData\Structure\Dictionaries\Dictionary\findIndexOfElement(), ILIAS\MetaData\Structure\Dictionaries\Tags\TagInterface\indices(), and ILIAS\MetaData\Structure\Dictionaries\Tags\TagInterface\isRestrictedToIndices().

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

87  : bool {
88  if (!($element instanceof ElementInterface)) {
89  return true;
90  }
91  if (!$tag->isRestrictedToIndices()) {
92  return true;
93  }
94  $index = $this->findIndexOfElement($path, $element);
95  if (in_array($index, iterator_to_array($tag->indices()), true)) {
96  return true;
97  }
98  return false;
99  }
findIndexOfElement(PathInterface $path, ElementInterface $element)
Definition: Dictionary.php:101
$path
Definition: ltiservices.php:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findIndexOfElement()

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

Definition at line 101 of file Dictionary.php.

References ILIAS\MetaData\Elements\Base\BaseElementInterface\getDefinition().

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

104  : int {
105  $name = $element->getDefinition()->name();
106  $navigator = $this->navigator_factory->navigator($path, $element);
107  $index = 0;
108  foreach ($navigator->elementsAtFinalStep() as $sibling_element) {
109  if ($sibling_element === $element) {
110  return $index;
111  }
112  $index++;
113  }
114  throw new \ilMDStructureException('Invalid metadata set');
115  }
$path
Definition: ltiservices.php:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAssignmentsForElement()

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

Definition at line 73 of file Dictionary.php.

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

75  : \Generator {
76  foreach ($this->tag_assignments as $assignment) {
77  if ($assignment->matchesPath($path)) {
78  yield $assignment;
79  }
80  }
81  }
$path
Definition: ltiservices.php:29
+ Here is the caller graph for this function:

◆ 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[]

Definition at line 57 of file Dictionary.php.

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

59  : \Generator {
60  $path = $this->path_factory->toElement($element);
61  foreach ($this->getAssignmentsForElement($path) as $assignment) {
62  $tag = $assignment->tag();
63  if (!$this->doesIndexMatch($path, $element, $tag)) {
64  continue;
65  }
66  yield $tag;
67  }
68  }
doesIndexMatch(PathInterface $path, BaseElementInterface $element, TagInterface $tag)
Definition: Dictionary.php:83
$path
Definition: ltiservices.php:29
+ 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: