ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ElementHelper.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27
29{
31 protected PathFactory $path_factory;
33 protected ConditionChecker $condition_checker;
34
35 public function __construct(
37 PathFactory $path_factory,
39 ConditionChecker $condition_checker
40 ) {
41 $this->slot_handler = $slot_handler;
42 $this->path_factory = $path_factory;
43 $this->navigator_factory = $navigator_factory;
44 $this->condition_checker = $condition_checker;
45 }
46
47 public function slotForElement(ElementInterface $element): Identifier
48 {
49 foreach ($this->slotsForElementWithoutCondition($element) as $slot) {
50 if ($this->condition_checker->doesElementFitSlot($element, $slot)) {
51 return $slot;
52 }
53 }
54 return Identifier::NULL;
55 }
56
60 public function slotsForElementWithoutCondition(ElementInterface $element): \Generator
61 {
62 yield from $this->slot_handler->allSlotsForPath($this->path_factory->toElement($element));
63 }
64
66 ElementInterface $element,
67 ElementInterface $element_in_condition,
68 string $value
69 ): Identifier {
70 return $this->slot_handler->identiferFromPathAndCondition(
71 $this->path_factory->toElement($element),
72 $this->path_factory->betweenElements($element, $element_in_condition),
73 $value,
74 );
75 }
76
77 public function findElementOfCondition(
78 Identifier $slot,
79 ElementInterface $element,
80 ElementInterface ...$all_elements
82 if (!$this->slot_handler->isSlotConditional($slot)) {
83 return null;
84 }
85
86 $condition_path = $this->slot_handler->conditionForSlot($slot)->path();
87 $potential_result = $this->navigator_factory->navigator($condition_path, $element)
88 ->lastElementAtFinalStep();
89
90 return in_array($potential_result, $all_elements, true) ? $potential_result : null;
91 }
92}
potentialSlotForElementByCondition(ElementInterface $element, ElementInterface $element_in_condition, string $value)
findElementOfCondition(Identifier $slot, ElementInterface $element, ElementInterface ... $all_elements)
slotsForElementWithoutCondition(ElementInterface $element)
__construct(HandlerInterface $slot_handler, PathFactory $path_factory, NavigatorFactoryInterface $navigator_factory, ConditionChecker $condition_checker)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists('../ilias.ini.php'))