- Now working properly with TextResponse, and anything else which is not Text, Json or HTML
This commit is contained in:
parent
912e456bde
commit
08a8683d59
|
@ -35,7 +35,7 @@ class Dump {
|
|||
$data = $this->getDumpContent();
|
||||
|
||||
return <<<HTML
|
||||
<pre style='-webkit-overflow-scrolling: touch;background-color: #f5f5f5;color: #4a4a4a;font-size: 12px;line-height:18px;overflow-x: auto;padding: 0.5rem 1.5rem;word-wrap: normal;white-space: pre;margin:0.33rem 0;'>
|
||||
<pre style='-webkit-overflow-scrolling: touch;background-color: #f5f5f5;color: #4a4a4a;font-size: 12px;line-height:18px;overflow-x: auto;padding: 0.5rem 1.5rem;word-wrap: normal;white-space: pre;margin:0.33rem 0;position: relative;z-index:9000000000;'>
|
||||
<div style='color:#9f9f9f;font-size:10px;' title='{$this->trace['file']}'>[ file: {$this->trace['file']}:{$this->trace['line']} ]</div>
|
||||
$data
|
||||
</pre>
|
||||
|
|
|
@ -7,10 +7,7 @@ namespace Dump {
|
|||
Psr\Http\Server\RequestHandlerInterface,
|
||||
Psr\Http\Message\ResponseInterface;
|
||||
|
||||
use Laminas\Diactoros\Response,
|
||||
Laminas\Diactoros\Stream,
|
||||
Laminas\Diactoros\Response\JsonResponse,
|
||||
Laminas\Diactoros\Response\HtmlResponse;
|
||||
use Laminas\Diactoros\{ Response, Stream, Response\JsonResponse, Response\HtmlResponse, Response\TextResponse };
|
||||
|
||||
use function stream_copy_to_stream;
|
||||
|
||||
|
@ -42,6 +39,16 @@ namespace Dump {
|
|||
};
|
||||
|
||||
switch (true) {
|
||||
case $response instanceof TextResponse:
|
||||
$body = $response->getBody();
|
||||
|
||||
foreach(static::$dump_stack as $item) {
|
||||
$stream->write($item->renderText());
|
||||
}
|
||||
|
||||
$stream->append_resource($body->detach());
|
||||
break;
|
||||
|
||||
case $response instanceof JsonResponse:
|
||||
foreach(static::$dump_stack as $item) {
|
||||
$dump[] = $item->renderArray();
|
||||
|
@ -50,6 +57,7 @@ namespace Dump {
|
|||
$stream->write(json_encode(array_merge([ "_dump" => $dump ?? [] ], json_decode($response->getBody()->getContents() ?? "{}", true)), JsonResponse::DEFAULT_JSON_FLAGS));
|
||||
break;
|
||||
|
||||
default:
|
||||
case $response instanceof Response:
|
||||
$body = $response->getBody();
|
||||
|
||||
|
|
Loading…
Reference in New Issue