ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
BaseConditionFactory.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
29 
30 abstract class BaseConditionFactory
31 {
36 
37  public function __construct(
38  UIFactory $ui_factory,
39  PresenterInterface $presenter,
40  ConstraintDictionary $constraint_dictionary,
42  ) {
43  $this->ui_factory = $ui_factory;
44  $this->presenter = $presenter;
45  $this->constraint_dictionary = $constraint_dictionary;
46  $this->types = $types;
47  }
48 
49  abstract protected function conditionInput(
50  ElementInterface $element,
51  ElementInterface $context_element,
52  ElementInterface ...$conditional_elements
53  ): FormInput;
54 
55  final public function getConditionInput(
56  ElementInterface $element,
57  ElementInterface $context_element,
58  ElementInterface ...$conditional_elements
59  ): FormInput {
60  $input = $this->conditionInput(
61  $element,
62  $context_element,
63  ...$conditional_elements
64  );
65 
66  return $this->finishInput($element, $context_element, $input);
67  }
68 
69  final protected function getInputInCondition(
70  ElementInterface $element,
71  ElementInterface $context_element,
72  string $condition_value
73  ): FormInput {
74  $input_factory = $this->types->factory($element->getDefinition()->dataType());
75  return $input_factory->getInputInCondition(
76  $element,
77  $context_element,
78  $condition_value
79  );
80  }
81 
82  final protected function finishInput(
83  ElementInterface $element,
84  ElementInterface $context_element,
85  FormInput $input
86  ): FormInput {
87  $input_factory = $this->types->factory($element->getDefinition()->dataType());
88  return $input_factory->finishInput(
89  $element,
90  $context_element,
91  $input
92  );
93  }
94 }
This is what a factory for input fields looks like.
Definition: Factory.php:28
__construct(UIFactory $ui_factory, PresenterInterface $presenter, ConstraintDictionary $constraint_dictionary, FactoryWithoutConditionTypesService $types)
getInputInCondition(ElementInterface $element, ElementInterface $context_element, string $condition_value)
conditionInput(ElementInterface $element, ElementInterface $context_element, ElementInterface ... $conditional_elements)
getDefinition()
Defining properties of the metadata element.
finishInput(ElementInterface $element, ElementInterface $context_element, FormInput $input)
This describes inputs that can be used in forms.
Definition: FormInput.php:31
getConditionInput(ElementInterface $element, ElementInterface $context_element, ElementInterface ... $conditional_elements)