79a27f7bd88b29f25e5ff1a7ffde5da3f8fb7f58
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Tests / Functional / SiteHandling / Fixtures / PhpError.php
1 <?php
2 namespace TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Fixtures;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use Psr\Http\Message\ResponseInterface;
18 use Psr\Http\Message\ServerRequestInterface;
19 use TYPO3\CMS\Core\Error\PageErrorHandler\PageErrorHandlerInterface;
20 use TYPO3\CMS\Core\Http\JsonResponse;
21
22 /**
23 * Test case for frontend requests without having site handling configured
24 */
25 class PhpError implements PageErrorHandlerInterface
26 {
27 /**
28 * @var int
29 */
30 private $statusCode;
31
32 /**
33 * @var array
34 */
35 private $configuration;
36
37 /**
38 * @param int $statusCode
39 * @param array $configuration
40 */
41 public function __construct(int $statusCode, array $configuration)
42 {
43 $this->statusCode = $statusCode;
44 $this->configuration = $configuration;
45 }
46
47 /**
48 * @param ServerRequestInterface $request
49 * @param string $message
50 * @param array $reasons
51 * @return ResponseInterface
52 */
53 public function handlePageError(
54 ServerRequestInterface $request,
55 string $message,
56 array $reasons = []
57 ): ResponseInterface {
58 $data = [
59 'uri' => (string)$request->getUri(),
60 'message' => $message,
61 'reasons' => $reasons,
62 ];
63 return new JsonResponse($data, $this->statusCode);
64 }
65 }