1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
namespace App\Http; |
6
|
|
|
|
7
|
|
|
use DarkMatter\Http\Response; |
8
|
|
|
use DarkMatter\Payload\Payload; |
9
|
|
|
use DarkMatter\Payload\Status; |
10
|
|
|
use DarkMatter\Responder\HtmlResponder; |
11
|
|
|
use DarkMatter\Components\PhtmlRenderer\Factory as RendererFactory; |
|
|
|
|
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @property string $view |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
class PayloadResponder extends HtmlResponder |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var \DarkMatter\Components\PhtmlRenderer\PhtmlRenderer $renderer |
|
|
|
|
21
|
|
|
*/ |
22
|
|
|
protected $renderer; |
23
|
|
|
|
24
|
|
|
public function __construct(array $config) |
25
|
|
|
{ |
26
|
|
|
$this->renderer = (new RendererFactory($config))->makeRenderer(); |
27
|
|
|
parent::__construct($config); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Generates a payload response. |
32
|
|
|
* |
33
|
|
|
* @param Payload $payload |
34
|
|
|
* @return Response |
35
|
|
|
*/ |
36
|
|
|
public function __invoke(Payload $payload): Response |
37
|
|
|
{ |
38
|
|
|
$body = $this->renderer->render('logs', [ |
|
|
|
|
39
|
|
|
'logs' => $data['logs'] ?? [], |
|
|
|
|
40
|
|
|
'sources' => $data['sources'] ?? [], |
41
|
|
|
'levels' => $data['levels'] ?? [], |
42
|
|
|
'filters' => $data['filters'] ?? [] |
43
|
|
|
]); |
44
|
|
|
|
45
|
|
|
///return $this->found(['body' => $body]); |
46
|
|
|
//exit; |
47
|
|
|
// payload |
48
|
|
|
$payloadResult = $payload->getResult(); |
49
|
|
|
|
50
|
|
|
if ($payload->getStatus() === Status::FOUND) { |
51
|
|
|
return $this->found($payloadResult); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
return $this->error([$payloadResult['error'] ?? 'Unknown Error']); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Respond with an not found message. |
59
|
|
|
* |
60
|
|
|
* @return Response |
61
|
|
|
*/ |
62
|
|
|
public function notFound(): Response |
63
|
|
|
{ |
64
|
|
|
echo 'own notfound method'; |
65
|
|
|
exit; |
|
|
|
|
66
|
|
|
$this->response->setStatus(404); |
|
|
|
|
67
|
|
|
$this->response->setBody('<html><title>404 Not found</title>404 Not found</html>'); |
68
|
|
|
return $this->response; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
|
73
|
|
|
|
74
|
|
|
|
75
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths