ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
LegacyRequestProxy.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use Psr\Http\Message\ServerRequestInterface;
24use Psr\Http\Message\MessageInterface;
25use Psr\Http\Message\UriInterface;
26use Psr\Http\Message\RequestInterface;
27use Psr\Http\Message\StreamInterface;
28
29class LegacyRequestProxy implements ServerRequestInterface
30{
31 private function request(): ServerRequestInterface
32 {
33 $dic = $GLOBALS['DIC'] ?? null;
34 if ($dic === null) {
35 throw new \RuntimeException('Global DIC is not initialized; cannot access HTTP request.');
36 }
37 return $dic->http()->request();
38 }
39
40 public function getProtocolVersion(): string
41 {
42 return $this->request()->getProtocolVersion();
43 }
44
45 public function withProtocolVersion(string $version): MessageInterface
46 {
47 return $this->request()->withProtocolVersion($version);
48 }
49
50 public function getHeaders(): array
51 {
52 return $this->request()->getHeaders();
53 }
54
55 public function hasHeader(string $name): bool
56 {
57 return $this->request()->hasHeader($name);
58 }
59
60 public function getHeader(string $name): array
61 {
62 return $this->request()->getHeader($name);
63 }
64
65 public function getHeaderLine(string $name): string
66 {
67 return $this->request()->getHeaderLine($name);
68 }
69
70 public function withHeader(string $name, $value): MessageInterface
71 {
72 return $this->request()->withHeader($name, $value);
73 }
74
75 public function withAddedHeader(string $name, $value): MessageInterface
76 {
77 return $this->request()->withAddedHeader($name, $value);
78 }
79
80 public function withoutHeader(string $name): MessageInterface
81 {
82 return $this->request()->withoutHeader($name);
83 }
84
85 public function getBody(): StreamInterface
86 {
87 return $this->request()->getBody();
88 }
89
90 public function withBody(StreamInterface $body): MessageInterface
91 {
92 return $this->request()->withBody($body);
93 }
94
95 public function getRequestTarget(): string
96 {
97 return $this->request()->getRequestTarget();
98 }
99
100 public function withRequestTarget(string $requestTarget): RequestInterface
101 {
102 return $this->request()->withRequestTarget($requestTarget);
103 }
104
105 public function getMethod(): string
106 {
107 return $this->request()->getMethod();
108 }
109
110 public function withMethod(string $method): RequestInterface
111 {
112 return $this->request()->withMethod($method);
113 }
114
115 public function getUri(): UriInterface
116 {
117 return $this->request()->getUri();
118 }
119
120 public function withUri(UriInterface $uri, bool $preserveHost = false): RequestInterface
121 {
122 return $this->request()->withUri($uri, $preserveHost);
123 }
124
125 public function getServerParams(): array
126 {
127 return $this->request()->getServerParams();
128 }
129
130 public function getCookieParams(): array
131 {
132 return $this->request()->getCookieParams();
133 }
134
135 public function withCookieParams(array $cookies): ServerRequestInterface
136 {
137 return $this->request()->withCookieParams($cookies);
138 }
139
140 public function getQueryParams(): array
141 {
142 return $this->request()->getQueryParams();
143 }
144
145 public function withQueryParams(array $query): ServerRequestInterface
146 {
147 return $this->request()->withQueryParams($query);
148 }
149
150 public function getUploadedFiles(): array
151 {
152 return $this->request()->getUploadedFiles();
153 }
154
155 public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface
156 {
157 return $this->request()->withUploadedFiles($uploadedFiles);
158 }
159
160 public function getParsedBody()
161 {
162 return $this->request()->getParsedBody();
163 }
164
165 public function withParsedBody($data): ServerRequestInterface
166 {
167 return $this->request()->withParsedBody($data);
168 }
169
170 public function getAttributes(): array
171 {
172 return $this->request()->getAttributes();
173 }
174
175 public function getAttribute(string $name, $default = null)
176 {
177 return $this->request()->getAttribute($name, $default);
178 }
179
180 public function withAttribute(string $name, $value): ServerRequestInterface
181 {
182 return $this->request()->withAttribute($name, $value);
183 }
184
185 public function withoutAttribute(string $name): ServerRequestInterface
186 {
187 return $this->request()->withoutAttribute($name);
188 }
189}
$version
Definition: plugin.php:24
getAttribute(string $name, $default=null)
withUri(UriInterface $uri, bool $preserveHost=false)
$dic
Definition: ltiresult.php:33
$GLOBALS["DIC"]
Definition: wac.php:54