ILIAS  release_8 Revision v8.24
Group.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28use ILIAS\UI\Implementation\Component\ComponentHelper;
29use ILIAS\Data\Factory as DataFactory;
30use ilLanguage;
32use Closure;
34use Generator;
37use ILIAS\UI\Component\Input\Field\Input as LegacyInputInterface;
38
43{
44 use GroupInternals;
45 protected ilLanguage $lng;
46
50 public function __construct(
51 DataFactory $data_factory,
52 \ILIAS\Refinery\Factory $refinery,
54 array $inputs,
55 string $label,
56 ?string $byline = null
57 ) {
58 parent::__construct($data_factory, $refinery, $label, $byline);
59 $this->checkInputListElements('inputs', $inputs, [C\Input\Container\Form\FormInput::class]);
60 $this->setInputs($inputs);
61 $this->lng = $lng;
62 }
63
64 public function withDisabled(bool $is_disabled): LegacyInputInterface
65 {
66 $clone = parent::withDisabled($is_disabled);
67 $clone->setInputs(array_map(fn ($i) => $i->withDisabled($is_disabled), $this->getInputs()));
68 return $clone;
69 }
70
71 public function withRequired(bool $is_required, ?Constraint $requirement_constraint = null): LegacyInputInterface
72 {
73 $clone = parent::withRequired($is_required, $requirement_constraint);
74 $clone->setInputs(array_map(fn ($i) => $i->withRequired($is_required, $requirement_constraint), $this->getInputs()));
75 return $clone;
76 }
77
78 public function isRequired(): bool
79 {
80 if ($this->is_required) {
81 return true;
82 }
83 foreach ($this->getInputs() as $input) {
84 if ($input->isRequired()) {
85 return true;
86 }
87 }
88 return false;
89 }
90
91 public function withOnUpdate(Signal $signal)
92 {
93 $clone = parent::withOnUpdate($signal);
94 $clone->setInputs(array_map(fn ($i) => $i->withOnUpdate($signal), $this->getInputs()));
95 return $clone;
96 }
97
102 {
103 return null;
104 }
105
109 public function getUpdateOnLoadCode(): Closure
110 {
111 return function () {
112 /*
113 * Currently, there is no use case for Group here. The single Inputs
114 * within the Group are responsible for handling getUpdateOnLoadCode().
115 */
116 };
117 }
118
122 public function withNameFrom(NameSource $source, ?string $parent_name = null): LegacyInputInterface
123 {
125 $clone = parent::withNameFrom($source, $parent_name);
126 $clone->setInputs($this->nameInputs($source, $clone->getName()));
127 return $clone;
128 }
129
133 public function getContent(): Result
134 {
135 if (empty($this->getInputs())) {
136 return new Ok([]);
137 }
138 return parent::getContent();
139 }
140
144 protected function setError(string $error): void
145 {
146 $this->error = $error;
147 }
148
149 protected function getLanguage(): \ilLanguage
150 {
151 return $this->lng;
152 }
153
154 protected function getDataFactory(): DataFactory
155 {
156 return $this->data_factory;
157 }
158
160 protected function isClientSideValueOk($value): bool
161 {
162 return $this->_isClientSideValueOk($value);
163 }
164}
Factory for Date Formats.
Definition: Factory.php:27
Builds data types.
Definition: Factory.php:21
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Ok.php:17
This implements the group input.
Definition: Group.php:43
getContent()
Get the current content of the input.
Definition: Group.php:133
__construct(DataFactory $data_factory, \ILIAS\Refinery\Factory $refinery, ilLanguage $lng, array $inputs, string $label, ?string $byline=null)
Definition: Group.php:50
getUpdateOnLoadCode()
Get update code.This method has to return JS code that calls il.UI.filter.onFieldUpdate(event,...
Definition: Group.php:109
withDisabled(bool $is_disabled)
Get an input like this, but set it to a disabled state.
Definition: Group.php:64
withOnUpdate(Signal $signal)
Trigger a signal of another component on update.
Definition: Group.php:91
withRequired(bool $is_required, ?Constraint $requirement_constraint=null)
Get an input like this, but set the field to be required (or not).
Definition: Group.php:71
This is a legacy support of Implementation\Component\Input\Field\Input that has been moved to Impleme...
Definition: Input.php:32
ilErrorHandling $error
Definition: class.ilias.php:55
error(string $a_errmsg)
language handling
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:15
A constraint encodes some resrtictions on values.
Definition: Constraint.php:32
This describes inputs that can be used in forms.
Definition: FormInput.php:32
This is a legacy support of Component\Input\Field\Input that has been moved to Component\Input\Contai...
Definition: Input.php:32
Describes how Input-Elements want to interact with posted data.
Definition: InputData.php:30
withNameFrom(NameSource $source)
Get an input like this one, with a different name.
Describes a source for input names.
Definition: NameSource.php:27
$i
Definition: metadata.php:41
$source
Definition: metadata.php:93
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Refinery Factory $refinery
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Checkbox.php:21
withNameFrom(NameSource $source, ?string $parent_name=null)
@inheritDoc
nameInputs(NameSource $source, string $parent_name)
Definition: Group.php:114
_isClientSideValueOk($value)
ATTENTION: This is not the same as.
Definition: Group.php:129
setInputs(array $inputs)
This setter should be used instead of accessing $this->inputs directly.
Definition: Group.php:161
Class ChatMainBarProvider \MainMenu\Provider.