ILIAS  release_8 Revision v8.23
Group.php
Go to the documentation of this file.
1 <?php
2 
18 declare(strict_types=1);
19 
21 
23 use ILIAS\UI\Component\Input\ViewControl\Group as ViewControlGroupInterface;
33 
37 class Group extends ViewControlInput implements ViewControlGroupInterface, GroupInternal
38 {
39  use GroupInternals;
40 
41  protected \ilLanguage $language;
42 
43  public function __construct(
44  DataFactory $data_factory,
46  \ilLanguage $language,
47  array $inputs
48  ) {
49  parent::__construct($data_factory, $refinery);
50  $this->language = $language;
51  $this->checkInputListElements('inputs', $inputs, [ViewControlInputInterface::class]);
52  $this->setInputs($inputs);
53  }
54 
58  public function withNameFrom(NameSource $source, ?string $parent_name = null): self
59  {
61  $clone = parent::withNameFrom($source, $parent_name);
62  $clone->setInputs($this->nameInputs($source, $clone->getName()));
63  return $clone;
64  }
65 
69  public function getContent(): Result
70  {
71  if (empty($this->getInputs())) {
72  return new Ok([]);
73  }
74  return parent::getContent();
75  }
76 
77  public function withOnChange(Signal $change_signal): self
78  {
79  $clone = parent::withOnChange($change_signal);
80  $clone->setInputs(array_map(static fn ($i) => $i->withOnChange($change_signal), $clone->getInputs()));
81  return $clone;
82  }
83 
87  protected function setError(string $error): void
88  {
89  $this->error = $error;
90  }
91 
92  protected function getLanguage(): \ilLanguage
93  {
94  return $this->language;
95  }
96 
97  protected function getDataFactory(): DataFactory
98  {
99  return $this->data_factory;
100  }
101 
103  protected function isClientSideValueOk($value): bool
104  {
105  return $this->_isClientSideValueOk($value);
106  }
107 }
Describes the monoid operation of grouping view control inputs.
Definition: Group.php:28
__construct(DataFactory $data_factory, Refinery $refinery, \ilLanguage $language, array $inputs)
Definition: Group.php:43
setInputs(array $inputs)
This setter should be used instead of accessing $this->inputs directly.
Definition: Group.php:161
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:14
nameInputs(NameSource $source, string $parent_name)
Definition: Group.php:114
_isClientSideValueOk($value)
ATTENTION: This is not the same as.
Definition: Group.php:129
Groups are a special kind of input because they are a monoid operation.
Definition: Group.php:36
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Ok.php:16
getContent()
Get the current content of the input.
Definition: Group.php:69
withNameFrom(NameSource $source, ?string $parent_name=null)
__construct(Container $dic, ilPlugin $plugin)
ilErrorHandling $error
Definition: class.ilias.php:55
Describes a source for input names.
Definition: NameSource.php:26
$source
Definition: metadata.php:93
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21
$i
Definition: metadata.php:41
Refinery Factory $refinery