ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ViewControl.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27use Psr\Http\Message\ServerRequestInterface;
31use ILIAS\Data\Factory as DataFactory;
36use ILIAS\Refinery\Factory as Refinery;
39
40abstract class ViewControl extends Container implements I\ViewControl
41{
43
45 protected ?ServerRequestInterface $request = null;
47
51 public function __construct(
52 SignalGeneratorInterface $signal_generator,
54 C\Input\ViewControl\Factory $view_control_factory,
55 array $controls
56 ) {
58 $this->setInputGroup($view_control_factory->group($controls)->withDedicatedName('view_control'));
59 $this->submit_signal = $signal_generator->create();
60 $this->stored_input = new Input\ArrayInputData([]);
61 }
62
63 public function getSubmissionSignal(): Signal
64 {
66 }
67
71 public function withRequest(ServerRequestInterface $request): Container
72 {
73 $clone = parent::withRequest($request);
74 $clone->request = $request;
75 return $clone;
76 }
77
78 public function getRequest(): ?ServerRequestInterface
79 {
80 return $this->request;
81 }
82
83 public function withStoredInput(Input\ArrayInputData $input): self
84 {
85 $clone = clone $this;
86 $clone->stored_input = $input;
87 return $clone;
88 }
89
93 protected function extractRequestData(ServerRequestInterface $request): InputData
94 {
95 $internal_input_data = new Input\ArrayInputData($this->getComponentInternalValues());
96
97 return new StackedInputData(
99 $this->stored_input,
100 $internal_input_data,
101 );
102 }
103
108 ?C\Input\Group $component = null,
109 array $input_values = []
110 ): array {
111 if (is_null($component)) {
112 $component = $this->getInputGroup();
113 }
114 foreach ($component->getInputs() as $input) {
115 if ($input instanceof C\Input\Group) {
116 $input_values = $this->getComponentInternalValues($input, $input_values);
117 }
118 if ($input instanceof HasInputGroup) {
119 $input_values = $this->getComponentInternalValues($input->getInputGroup(), $input_values);
120 }
121 if ($name = $input->getName()) {
122 $input_values[$input->getName()] = $input->getValue();
123 }
124 }
125
126 return $input_values;
127 }
128}
Builds data types.
Definition: Factory.php:36
This implements commonalities between all forms.
Definition: Container.php:35
setInputGroup(C\Input\Group $input_group)
This setter should be used in the constructor only, to initialize the group input property.
Definition: Container.php:142
__construct(SignalGeneratorInterface $signal_generator, Input\NameSource $name_source, C\Input\ViewControl\Factory $view_control_factory, array $controls)
Definition: ViewControl.php:51
getComponentInternalValues(?C\Input\Group $component=null, array $input_values=[])
extractRequestData(ServerRequestInterface $request)
@inheritDoc
Definition: ViewControl.php:93
Implements interaction of input element with get data from psr-7 server request.
Implements interaction of input element with get data from psr-7 server request.
A transformation is a function from one datatype to another.
Describes how Input-Elements want to interact with posted data.
Definition: InputData.php:30
This describes commonalities between all inputs.
Definition: Input.php:47
Describes a source for input names.
Definition: NameSource.php:27
create(string $class='')
Create a signal, each created signal MUST have a unique ID.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
if(!file_exists('../ilias.ini.php'))