ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Group.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 use ILIAS\UI\Component as C;
32 use Closure;
34 use Generator;
36 
41 {
42  use GroupInternals;
43 
47  public function __construct(
48  DataFactory $data_factory,
50  protected Language $lng,
51  array $inputs,
52  string $label,
53  ?string $byline = null
54  ) {
55  parent::__construct($data_factory, $refinery, $label, $byline);
56  $this->checkInputListElements('inputs', $inputs, [C\Input\Container\Form\FormInput::class]);
57  $this->setInputs($inputs);
58  }
59 
60  public function withDisabled(bool $is_disabled): self
61  {
62  $clone = parent::withDisabled($is_disabled);
63  $clone->setInputs(array_map(fn($i) => $i->withDisabled($is_disabled), $this->getInputs()));
64  return $clone;
65  }
66 
68  {
69  $clone = parent::withRequired($is_required, $requirement_constraint);
70  $clone->setInputs(array_map(fn($i) => $i->withRequired($is_required, $requirement_constraint), $this->getInputs()));
71  return $clone;
72  }
73 
74  public function isRequired(): bool
75  {
76  if ($this->is_required) {
77  return true;
78  }
79  foreach ($this->getInputs() as $input) {
80  if ($input->isRequired()) {
81  return true;
82  }
83  }
84  return false;
85  }
86 
87  public function withOnUpdate(Signal $signal): self
88  {
89  $clone = parent::withOnUpdate($signal);
90  $clone->setInputs(array_map(fn($i) => $i->withOnUpdate($signal), $this->getInputs()));
91  return $clone;
92  }
93 
97  protected function getConstraintForRequirement(): ?Constraint
98  {
99  return null;
100  }
101 
105  public function getUpdateOnLoadCode(): Closure
106  {
107  return function () {
108  /*
109  * Currently, there is no use case for Group here. The single Inputs
110  * within the Group are responsible for handling getUpdateOnLoadCode().
111  */
112  };
113  }
114 
118  public function withNameFrom(NameSource $source, ?string $parent_name = null): self
119  {
121  $clone = parent::withNameFrom($source, $parent_name);
122  $clone->setInputs($this->nameInputs($source, $clone->getName()));
123  return $clone;
124  }
125 
129  public function getContent(): Result
130  {
131  if (empty($this->getInputs())) {
132  return new Ok([]);
133  }
134  return parent::getContent();
135  }
136 
140  protected function setError(string $error): void
141  {
142  $this->error = $error;
143  }
144 
145  protected function getLanguage(): Language
146  {
147  return $this->lng;
148  }
149 
150  protected function getDataFactory(): DataFactory
151  {
152  return $this->data_factory;
153  }
154 
156  protected function isClientSideValueOk($value): bool
157  {
158  return $this->_isClientSideValueOk($value);
159  }
160 }
This implements commonalities between inputs.
Definition: Input.php:42
withRequired(bool $is_required, ?Constraint $requirement_constraint=null)
Definition: Group.php:67
getContent()
Get the current content of the input.
Definition: Group.php:129
Interface Observer Contains several chained tasks and infos about them.
setInputs(array $inputs)
This setter should be used instead of accessing $this->inputs directly.
Definition: Group.php:163
A constraint encodes some resrtictions on values.
Definition: Constraint.php:31
__construct(DataFactory $data_factory, \ILIAS\Refinery\Factory $refinery, protected Language $lng, array $inputs, string $label, ?string $byline=null)
Definition: Group.php:47
nameInputs(NameSource $source, string $parent_name)
Definition: Group.php:116
This implements commonalities between all forms.
Definition: Form.php:33
Factory for Date Formats.
Definition: Factory.php:26
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Checkbox.php:21
_isClientSideValueOk($value)
ATTENTION: This is not the same as.
Definition: Group.php:131
withNameFrom(NameSource $source, ?string $parent_name=null)
Definition: Input.php:200
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Ok.php:30
string $error
This is an error on the input as displayed client side.
Definition: Input.php:57
withNameFrom(NameSource $source, ?string $parent_name=null)
__construct(Container $dic, ilPlugin $plugin)
global $lng
Definition: privfeed.php:31
This describes inputs that can be used in forms.
Definition: FormInput.php:32
Describes a source for input names.
Definition: NameSource.php:26