ILIAS  release_7 Revision v7.30-3-g800a261c036
PostDataFromServerRequest.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2017 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6
8
9use Psr\Http\Message\ServerRequestInterface;
10
16{
17
21 protected $parsed_body;
22
23
24 public function __construct(ServerRequestInterface $request)
25 {
26 $this->parsed_body = $request->getParsedBody();
27 }
28
29
33 public function get($name)
34 {
35 if (!isset($this->parsed_body[$name])) {
36 throw new \LogicException("'$name' is not contained in posted data.");
37 }
38
39 return $this->parsed_body[$name];
40 }
41
42
46 public function getOr($name, $default)
47 {
48 if (!isset($this->parsed_body[$name])) {
49 return $default;
50 }
51
52 return $this->parsed_body[$name];
53 }
54}
An exception for terminatinating execution or to throw for unit testing.
Implements interaction of input element with post data from psr-7 server request.
Describes how Input-Elements want to interact with posted data.
Definition: InputData.php:13
if($format !==null) $name
Definition: metadata.php:230