‪TYPO3CMS  ‪main
Request.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
18 namespace ‪TYPO3\CMS\Extbase\Mvc;
19 
20 use Psr\Http\Message\ServerRequestInterface;
21 use Psr\Http\Message\StreamInterface;
22 use Psr\Http\Message\UriInterface;
23 
35 {
36  protected ServerRequestInterface ‪$request;
37 
38  final public function ‪__construct(ServerRequestInterface ‪$request)
39  {
40  if (!‪$request->getAttribute('extbase') instanceof ‪ExtbaseRequestParameters) {
41  throw new \InvalidArgumentException(
42  'Given request must have an attribute "extbase" of type ExtbaseAttribute',
43  1624452070
44  );
45  }
46  $this->request = ‪$request;
47  }
48 
54  {
55  return $this->request->getAttribute('extbase');
56  }
57 
58  public function ‪getControllerObjectName(): string
59  {
60  return $this->‪getExtbaseAttribute()->getControllerObjectName();
61  }
62 
66  public function ‪withControllerObjectName(string $controllerObjectName): self
67  {
68  $attribute = clone $this->‪getExtbaseAttribute();
69  $attribute->setControllerObjectName($controllerObjectName);
70  return $this->‪withAttribute('extbase', $attribute);
71  }
72 
76  public function ‪getPluginName(): string
77  {
78  return $this->‪getExtbaseAttribute()->getPluginName();
79  }
80 
84  public function ‪withPluginName(string $pluginName): self
85  {
86  $attribute = clone $this->‪getExtbaseAttribute();
87  $attribute->setPluginName($pluginName);
88  return $this->‪withAttribute('extbase', $attribute);
89  }
90 
94  public function ‪getControllerExtensionName(): string
95  {
96  return $this->‪getExtbaseAttribute()->getControllerExtensionName();
97  }
98 
102  public function ‪withControllerExtensionName(string $controllerExtensionName): self
103  {
104  $attribute = clone $this->‪getExtbaseAttribute();
105  $attribute->setControllerExtensionName($controllerExtensionName);
106  return $this->‪withAttribute('extbase', $attribute);
107  }
108 
112  public function ‪getControllerExtensionKey(): string
113  {
114  return $this->‪getExtbaseAttribute()->getControllerExtensionKey();
115  }
116 
121  public function ‪getControllerName(): string
122  {
123  return $this->‪getExtbaseAttribute()->getControllerName();
124  }
125 
129  public function ‪withControllerName(string $controllerName): self
130  {
131  $attribute = clone $this->‪getExtbaseAttribute();
132  $attribute->setControllerName($controllerName);
133  return $this->‪withAttribute('extbase', $attribute);
134  }
135 
139  public function ‪getControllerActionName(): string
140  {
141  return $this->‪getExtbaseAttribute()->getControllerActionName();
142  }
143 
148  public function ‪withControllerActionName(string $actionName): self
149  {
150  $attribute = clone $this->‪getExtbaseAttribute();
151  $attribute->setControllerActionName($actionName);
152  return $this->‪withAttribute('extbase', $attribute);
153  }
154 
155  public function ‪getArguments(): array
156  {
157  return $this->‪getExtbaseAttribute()->getArguments();
158  }
159 
164  public function ‪withArguments(array $arguments): self
165  {
166  $attribute = clone $this->‪getExtbaseAttribute();
167  $attribute->setArguments($arguments);
168  return $this->‪withAttribute('extbase', $attribute);
169  }
170 
171  public function ‪getArgument(string $argumentName): mixed
172  {
173  return $this->‪getExtbaseAttribute()->getArgument($argumentName);
174  }
175 
176  public function ‪hasArgument(string $argumentName): bool
177  {
178  return $this->‪getExtbaseAttribute()->hasArgument($argumentName);
179  }
180 
184  public function ‪withArgument(string $argumentName, mixed $value): self
185  {
186  $attribute = clone $this->‪getExtbaseAttribute();
187  $attribute->setArgument($argumentName, $value);
188  return $this->‪withAttribute('extbase', $attribute);
189  }
190 
195  public function ‪getFormat(): string
196  {
197  return $this->‪getExtbaseAttribute()->getFormat();
198  }
199 
206  public function ‪withFormat(string $format): self
207  {
208  $attribute = clone $this->‪getExtbaseAttribute();
209  $attribute->setFormat($format);
210  return $this->‪withAttribute('extbase', $attribute);
211  }
212 
216  public function ‪getServerParams(): array
217  {
218  return $this->request->getServerParams();
219  }
220 
221  public function ‪getCookieParams(): array
222  {
223  return $this->request->getCookieParams();
224  }
225 
226  public function ‪withCookieParams(array $cookies): self
227  {
228  ‪$request = $this->request->withCookieParams($cookies);
229  return new static(‪$request);
230  }
231 
232  public function ‪getQueryParams(): array
233  {
234  return $this->request->getQueryParams();
235  }
236 
237  public function ‪withQueryParams(array $query): self
238  {
239  ‪$request = $this->request->withQueryParams($query);
240  return new static(‪$request);
241  }
242 
243  public function ‪getUploadedFiles(): array
244  {
245  return $this->‪getExtbaseAttribute()->getUploadedFiles();
246  }
247 
248  public function ‪withUploadedFiles(array $uploadedFiles): self
249  {
250  $attribute = clone $this->‪getExtbaseAttribute();
251  $attribute->setUploadedFiles($uploadedFiles);
252  return $this->‪withAttribute('extbase', $attribute);
253  }
254 
255  public function ‪getParsedBody()
256  {
257  return $this->request->getParsedBody();
258  }
259 
260  public function ‪withParsedBody($data): self
261  {
262  ‪$request = $this->request->withParsedBody($data);
263  return new static(‪$request);
264  }
265 
266  public function ‪getAttributes(): array
267  {
268  return $this->request->getAttributes();
269  }
270 
271  public function ‪getAttribute($name, $default = null)
272  {
273  return $this->request->getAttribute($name, $default);
274  }
275 
276  public function ‪withAttribute($name, $value): self
277  {
278  ‪$request = $this->request->withAttribute($name, $value);
279  return new static(‪$request);
280  }
281 
282  public function ‪withoutAttribute($name): ServerRequestInterface
283  {
284  ‪$request = $this->request->withoutAttribute($name);
285  if ($name === 'extbase') {
286  return ‪$request;
287  }
288  return new static(‪$request);
289  }
290 
294  public function ‪getRequestTarget(): string
295  {
296  return $this->request->getRequestTarget();
297  }
298 
299  public function ‪withRequestTarget($requestTarget): self
300  {
301  ‪$request = $this->request->withRequestTarget($requestTarget);
302  return new static(‪$request);
303  }
304 
305  public function ‪getMethod(): string
306  {
307  return $this->request->getMethod();
308  }
309 
310  public function ‪withMethod($method): self
311  {
312  ‪$request = $this->request->withMethod($method);
313  return new static(‪$request);
314  }
315 
316  public function ‪getUri(): UriInterface
317  {
318  return $this->request->getUri();
319  }
320 
321  public function ‪withUri(UriInterface $uri, $preserveHost = false): self
322  {
323  ‪$request = $this->request->withUri($uri, $preserveHost);
324  return new static(‪$request);
325  }
326 
330  public function ‪getProtocolVersion(): string
331  {
332  return $this->request->getProtocolVersion();
333  }
334 
335  public function ‪withProtocolVersion($version): self
336  {
337  ‪$request = $this->request->withProtocolVersion($version);
338  return new static(‪$request);
339  }
340 
341  public function ‪getHeaders(): array
342  {
343  return $this->request->getHeaders();
344  }
345 
346  public function ‪hasHeader($name): bool
347  {
348  return $this->request->hasHeader($name);
349  }
350 
351  public function ‪getHeader($name): array
352  {
353  return $this->request->getHeader($name);
354  }
355 
356  public function ‪getHeaderLine($name): string
357  {
358  return $this->request->getHeaderLine($name);
359  }
360 
361  public function ‪withHeader($name, $value): self
362  {
363  ‪$request = $this->request->withHeader($name, $value);
364  return new static(‪$request);
365  }
366 
367  public function ‪withAddedHeader($name, $value): self
368  {
369  ‪$request = $this->request->withAddedHeader($name, $value);
370  return new static(‪$request);
371  }
372 
373  public function ‪withoutHeader($name): self
374  {
375  ‪$request = $this->request->withoutHeader($name);
376  return new static(‪$request);
377  }
378 
379  public function ‪getBody(): StreamInterface
380  {
381  return $this->request->getBody();
382  }
383 
384  public function ‪withBody(StreamInterface $body): self
385  {
386  ‪$request = $this->request->withBody($body);
387  return new static(‪$request);
388  }
389 }
‪TYPO3\CMS\Extbase\Mvc\Request\getQueryParams
‪getQueryParams()
Definition: Request.php:232
‪TYPO3\CMS\Extbase\Mvc\Request\withMethod
‪withMethod($method)
Definition: Request.php:310
‪TYPO3\CMS\Extbase\Mvc\Request\getControllerExtensionName
‪getControllerExtensionName()
Definition: Request.php:94
‪TYPO3\CMS\Extbase\Mvc\Request\getControllerExtensionKey
‪getControllerExtensionKey()
Definition: Request.php:112
‪TYPO3\CMS\Extbase\Mvc\Request\getExtbaseAttribute
‪getExtbaseAttribute()
Definition: Request.php:53
‪TYPO3\CMS\Extbase\Mvc\Request\withFormat
‪withFormat(string $format)
Definition: Request.php:206
‪TYPO3\CMS\Extbase\Mvc\Request\withProtocolVersion
‪withProtocolVersion($version)
Definition: Request.php:335
‪TYPO3\CMS\Extbase\Mvc\Request\getControllerObjectName
‪getControllerObjectName()
Definition: Request.php:58
‪TYPO3\CMS\Extbase\Mvc\Request\getPluginName
‪getPluginName()
Definition: Request.php:76
‪TYPO3\CMS\Extbase\Mvc\Request\withArguments
‪withArguments(array $arguments)
Definition: Request.php:164
‪TYPO3\CMS\Extbase\Mvc\Request\withArgument
‪withArgument(string $argumentName, mixed $value)
Definition: Request.php:184
‪TYPO3\CMS\Extbase\Mvc\Request\getRequestTarget
‪getRequestTarget()
Definition: Request.php:294
‪TYPO3\CMS\Extbase\Mvc\Request\withControllerExtensionName
‪withControllerExtensionName(string $controllerExtensionName)
Definition: Request.php:102
‪TYPO3\CMS\Extbase\Mvc
‪TYPO3\CMS\Extbase\Mvc\Request\getUri
‪getUri()
Definition: Request.php:316
‪TYPO3\CMS\Extbase\Mvc\Request\getHeader
‪getHeader($name)
Definition: Request.php:351
‪TYPO3\CMS\Extbase\Mvc\Request\hasHeader
‪hasHeader($name)
Definition: Request.php:346
‪TYPO3\CMS\Extbase\Mvc\Request\getArguments
‪getArguments()
Definition: Request.php:155
‪TYPO3\CMS\Extbase\Mvc\Request\getMethod
‪getMethod()
Definition: Request.php:305
‪TYPO3\CMS\Extbase\Mvc\Request\withoutAttribute
‪withoutAttribute($name)
Definition: Request.php:282
‪TYPO3\CMS\Extbase\Mvc\Request\withCookieParams
‪withCookieParams(array $cookies)
Definition: Request.php:226
‪TYPO3\CMS\Extbase\Mvc\Request\getUploadedFiles
‪getUploadedFiles()
Definition: Request.php:243
‪TYPO3\CMS\Extbase\Mvc\Request\withAddedHeader
‪withAddedHeader($name, $value)
Definition: Request.php:367
‪TYPO3\CMS\Extbase\Mvc\Request\getCookieParams
‪getCookieParams()
Definition: Request.php:221
‪TYPO3\CMS\Extbase\Mvc\Request\getArgument
‪getArgument(string $argumentName)
Definition: Request.php:171
‪TYPO3\CMS\Extbase\Mvc\Request\__construct
‪__construct(ServerRequestInterface $request)
Definition: Request.php:38
‪TYPO3\CMS\Extbase\Mvc\Request\getFormat
‪getFormat()
Definition: Request.php:195
‪TYPO3\CMS\Extbase\Mvc\Request\withHeader
‪withHeader($name, $value)
Definition: Request.php:361
‪TYPO3\CMS\Extbase\Mvc\Request\withUri
‪withUri(UriInterface $uri, $preserveHost=false)
Definition: Request.php:321
‪TYPO3\CMS\Extbase\Mvc\Request\withQueryParams
‪withQueryParams(array $query)
Definition: Request.php:237
‪TYPO3\CMS\Extbase\Mvc\Request\withUploadedFiles
‪withUploadedFiles(array $uploadedFiles)
Definition: Request.php:248
‪TYPO3\CMS\Extbase\Mvc\Request\getControllerName
‪getControllerName()
Definition: Request.php:121
‪TYPO3\CMS\Extbase\Mvc\RequestInterface
Definition: RequestInterface.php:24
‪TYPO3\CMS\Extbase\Mvc\Request\getHeaders
‪getHeaders()
Definition: Request.php:341
‪TYPO3\CMS\Extbase\Mvc\Request\$request
‪ServerRequestInterface $request
Definition: Request.php:36
‪TYPO3\CMS\Extbase\Mvc\Request\withControllerName
‪withControllerName(string $controllerName)
Definition: Request.php:129
‪TYPO3\CMS\Extbase\Mvc\Request\withoutHeader
‪withoutHeader($name)
Definition: Request.php:373
‪TYPO3\CMS\Extbase\Mvc\Request\withAttribute
‪withAttribute($name, $value)
Definition: Request.php:276
‪TYPO3\CMS\Extbase\Mvc\Request\getServerParams
‪getServerParams()
Definition: Request.php:216
‪TYPO3\CMS\Extbase\Mvc\Request\getParsedBody
‪getParsedBody()
Definition: Request.php:255
‪TYPO3\CMS\Extbase\Mvc\Request\getProtocolVersion
‪getProtocolVersion()
Definition: Request.php:330
‪TYPO3\CMS\Extbase\Mvc\Request\withPluginName
‪withPluginName(string $pluginName)
Definition: Request.php:84
‪TYPO3\CMS\Extbase\Mvc\Request\withRequestTarget
‪withRequestTarget($requestTarget)
Definition: Request.php:299
‪TYPO3\CMS\Extbase\Mvc\Request\getAttribute
‪getAttribute($name, $default=null)
Definition: Request.php:271
‪TYPO3\CMS\Extbase\Mvc\ExtbaseRequestParameters
Definition: ExtbaseRequestParameters.php:35
‪TYPO3\CMS\Extbase\Mvc\Request\withBody
‪withBody(StreamInterface $body)
Definition: Request.php:384
‪TYPO3\CMS\Extbase\Mvc\Request
Definition: Request.php:35
‪TYPO3\CMS\Extbase\Mvc\Request\withControllerActionName
‪withControllerActionName(string $actionName)
Definition: Request.php:148
‪TYPO3\CMS\Extbase\Mvc\Request\getControllerActionName
‪getControllerActionName()
Definition: Request.php:139
‪TYPO3\CMS\Extbase\Mvc\Request\getAttributes
‪getAttributes()
Definition: Request.php:266
‪TYPO3\CMS\Extbase\Mvc\Request\withControllerObjectName
‪withControllerObjectName(string $controllerObjectName)
Definition: Request.php:66
‪TYPO3\CMS\Extbase\Mvc\Request\getHeaderLine
‪getHeaderLine($name)
Definition: Request.php:356
‪TYPO3\CMS\Extbase\Mvc\Request\getBody
‪getBody()
Definition: Request.php:379
‪TYPO3\CMS\Extbase\Mvc\Request\withParsedBody
‪withParsedBody($data)
Definition: Request.php:260
‪TYPO3\CMS\Extbase\Mvc\Request\hasArgument
‪hasArgument(string $argumentName)
Definition: Request.php:176