ILIAS  release_8 Revision v8.24
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;
38
40
41abstract class ViewControl extends Container implements I\ViewControl
42{
44
46 protected ?ServerRequestInterface $request = null;
47 protected Input\ArrayInputData $stored_input;
48
52 public function __construct(
53 SignalGeneratorInterface $signal_generator,
55 C\Input\ViewControl\Factory $view_control_factory,
56 array $controls
57 ) {
59 $this->setInputGroup($view_control_factory->group($controls)->withDedicatedName('view_control'));
60 $this->submit_signal = $signal_generator->create();
61 $this->stored_input = new Input\ArrayInputData([]);
62 }
63
64 public function getSubmissionSignal(): Signal
65 {
67 }
68
72 public function withRequest(ServerRequestInterface $request): Container
73 {
74 $clone = parent::withRequest($request);
75 $clone->request = $request;
76 return $clone;
77 }
78
79 public function getRequest(): ?ServerRequestInterface
80 {
81 return $this->request;
82 }
83
84 public function withStoredInput(Input\ArrayInputData $input): self
85 {
86 $clone = clone $this;
87 $clone->stored_input = $input;
88 return $clone;
89 }
90
94 protected function extractRequestData(ServerRequestInterface $request): InputData
95 {
96 $internal_input_data = new Input\ArrayInputData($this->getComponentInternalValues());
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:21
This implements commonalities between all forms.
Definition: Container.php:34
setInputGroup(C\Input\Group $input_group)
This setter should be used in the constructor only, to initialize the group input property.
Definition: Container.php:132
getComponentInternalValues(C\Input\Group $component=null, array $input_values=[])
__construct(SignalGeneratorInterface $signal_generator, Input\NameSource $name_source, C\Input\ViewControl\Factory $view_control_factory, array $controls)
Definition: ViewControl.php:52
extractRequestData(ServerRequestInterface $request)
@inheritDoc
Definition: ViewControl.php:94
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.
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
A transformation is a function from one datatype to another.
This describes commonalities between all inputs.
Definition: Input.php:49
Describes how Input-Elements want to interact with posted data.
Definition: InputData.php:30
Describes a source for input names.
Definition: NameSource.php:27
create(string $class='')
Create a signal, each created signal MUST have a unique ID.
if($format !==null) $name
Definition: metadata.php:247
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
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...
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.