ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Parser.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29
30class Parser implements ParserInterface
31{
32 protected HTTPWrapper $http;
33
34 public function __construct(HTTPWrapper $http)
35 {
36 $this->http = $http;
37 }
38
39 public function parseFromHTTP(URI $base_url): RequestInterface
40 {
41 $verb = Verb::NULL;
42 if ($this->http->requestHasArgument(Argument::VERB)) {
43 $verb = Verb::tryFrom($this->http->retrieveArgumentFromRequest(Argument::VERB)) ?? Verb::NULL;
44 }
45
46 $request = $this->getEmptyRequest($verb, $base_url);
47
48 foreach (Argument::cases() as $argument) {
49 if (
50 $argument === Argument::VERB ||
51 !$this->http->requestHasArgument($argument)
52 ) {
53 continue;
54 }
55 $request = $request->withArgument(
56 $argument,
57 rawurldecode($this->http->retrieveArgumentFromRequest($argument))
58 );
59 }
60
61 return $request;
62 }
63
64 protected function getEmptyRequest(Verb $verb, URI $base_url): RequestInterface
65 {
66 return new Request(
67 $base_url,
68 $verb
69 );
70 }
71}
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
getEmptyRequest(Verb $verb, URI $base_url)
Definition: Parser.php:64
static http()
Fetches the global http state from ILIAS.