ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
NonNegIntFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\Refinery\Factory as Refinery;
30
32{
34
35 public function __construct(
36 UIFactory $ui_factory,
38 ConstraintDictionary $constraint_dictionary,
40 ) {
42 $this->refinery = $refinery;
43 }
44
45 protected function rawInput(
46 ElementInterface $element,
47 ElementInterface $context_element,
48 SlotIdentifier $conditional_slot = SlotIdentifier::NULL
49 ): FormInput {
50 $input = $this->ui_factory
51 ->numeric($this->getInputLabelFromElement($this->presenter, $element, $context_element))
53 $this->refinery->int()->isGreaterThanOrEqual(0)
54 )
56 $this->refinery->byTrying([
57 $this->refinery->kindlyTo()->string(),
58 $this->refinery->kindlyTo()->null()
59 ])
60 );
61 return $this->addConstraintsFromElement(
62 $this->constraint_dictionary,
63 $element,
64 $this->addValueFromElement($element, $input)
65 );
66 }
67
68 public function getInput(
69 ElementInterface $element,
70 ElementInterface $context_element
71 ): FormInput {
72 return $this->rawInput($element, $context_element);
73 }
74
75 public function getInputInCondition(
76 ElementInterface $element,
77 ElementInterface $context_element,
78 SlotIdentifier $conditional_slot
79 ): FormInput {
80 return $this->rawInput($element, $context_element);
81 }
82}
Builds data types.
Definition: Factory.php:36
__construct(UIFactory $ui_factory, PresenterInterface $presenter, ConstraintDictionary $constraint_dictionary, Refinery $refinery)
getInput(ElementInterface $element, ElementInterface $context_element)
rawInput(ElementInterface $element, ElementInterface $context_element, SlotIdentifier $conditional_slot=SlotIdentifier::NULL)
getInputInCondition(ElementInterface $element, ElementInterface $context_element, SlotIdentifier $conditional_slot)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes inputs that can be used in forms.
Definition: FormInput.php:33
This is what a factory for input fields looks like.
Definition: Factory.php:31
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
withAdditionalTransformation(Transformation $trafo)
@inheritDoc