ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
StackedInputData.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
25 use LogicException;
26 
30 class StackedInputData implements InputData
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 }
Describes how Input-Elements want to interact with posted data.
Definition: InputData.php:29
if($format !==null) $name
Definition: metadata.php:247
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(InputData ... $stack)
Construct with any number of InputData.