ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
StackedInputData.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use Psr\Http\Message\ServerRequestInterface;
25use LogicException;
26
31{
32 protected array $stack;
33
39 public function __construct(InputData ...$stack)
40 {
41 $this->stack = $stack;
42 }
43
44 public function get(string $name)
45 {
46 foreach ($this->stack as $input) {
47 if ($input->has($name)) {
48 return $input->get($name);
49 }
50 }
51 throw new LogicException("'$name' is not contained in stack of input.");
52 }
53
54 public function getOr(string $name, $default)
55 {
56 foreach ($this->stack as $input) {
57 if ($input->has($name)) {
58 return $input->get($name);
59 }
60 }
61 return $default;
62 }
63
64 public function has($name): bool
65 {
66 foreach ($this->stack as $input) {
67 if ($input->has($name)) {
68 return true;
69 }
70 }
71 return false;
72 }
73}
Implements interaction of input element with get data from psr-7 server request.
getOr(string $name, $default)
Get a named value from the data and fallback to default if that name does not exist.
__construct(InputData ... $stack)
Construct with any number of InputData.
Describes how Input-Elements want to interact with posted data.
Definition: InputData.php:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...