ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
NonNegIntFactory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\Refinery\Factory as Refinery;
31
33{
35
36 public function __construct(
37 UIFactory $ui_factory,
39 ConstraintDictionary $constraint_dictionary,
41 ) {
43 $this->refinery = $refinery;
44 }
45
46 protected function rawInput(
47 ElementInterface $element,
48 ElementInterface $context_element,
49 SlotIdentifier $conditional_slot = SlotIdentifier::NULL
50 ): FormInput {
51 $input = $this->ui_factory
52 ->numeric($this->getInputLabelFromElement($this->presenter, $element, $context_element))
54 $this->refinery->int()->isGreaterThanOrEqual(0)
55 )
57 $this->refinery->byTrying([
58 $this->refinery->kindlyTo()->string(),
59 $this->refinery->kindlyTo()->null()
60 ])
61 );
62 return $this->addConstraintsFromElement(
63 $this->constraint_dictionary,
64 $element,
65 $this->addValueFromElement($element, $input)
66 );
67 }
68
69 public function getInput(
70 ElementInterface $element,
71 ElementInterface $context_element
72 ): FormInput {
73 return $this->rawInput($element, $context_element);
74 }
75
76 public function getInputInCondition(
77 ElementInterface $element,
78 ElementInterface $context_element,
79 SlotIdentifier $conditional_slot
80 ): FormInput {
81 return $this->rawInput($element, $context_element);
82 }
83}
Builds data types.
Definition: Factory.php:36
getInput(ElementInterface $element, ElementInterface $context_element)
rawInput(ElementInterface $element, ElementInterface $context_element, SlotIdentifier $conditional_slot=SlotIdentifier::NULL)
__construct(UIFactory $ui_factory, PresenterInterface $presenter, ConstraintDictionary $constraint_dictionary, Refinery $refinery)
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