mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 11:11:39 +09:00
Also print debug information when responding via JSON
This commit is contained in:
parent
f334879840
commit
e956ee88d7
1 changed files with 15 additions and 7 deletions
|
|
@ -176,13 +176,21 @@ class DisplayHandler extends Handler
|
||||||
{
|
{
|
||||||
case 'panel':
|
case 'panel':
|
||||||
$data = Rhymix\Framework\Debug::getDebugData();
|
$data = Rhymix\Framework\Debug::getDebugData();
|
||||||
$json_options = defined('JSON_PRETTY_PRINT') ? (JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) : 0;
|
switch (Context::getResponseMethod())
|
||||||
$panel_html = '<div id="rhymix_debug_panel"></div>';
|
{
|
||||||
$panel_script = 'var rhymix_debug_content = ' . json_encode($data, $json_options) . ';';
|
case 'HTML':
|
||||||
$replace_html = '<div id="rhymix_debug_panel">' . "\n" . '<script>' . "\n" . $panel_script . "\n" . '</script>' . "\n" . '</div>';
|
$json_options = defined('JSON_PRETTY_PRINT') ? (JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) : 0;
|
||||||
$output = str_replace($panel_html, $replace_html, $output);
|
$panel_script = "<script>\nvar rhymix_debug_content = " . json_encode($data, $json_options) . ";\n</script>";
|
||||||
break;
|
$body_end_position = strrpos($output, '</body>') ?: strlen($output);
|
||||||
|
$output = substr($output, 0, $body_end_position) . "\n$panel_script\n" . substr($output, $body_end_position);
|
||||||
|
return;
|
||||||
|
case 'JSON':
|
||||||
|
$output = preg_replace('/\}$/', ',"_rx_debug":' . json_encode($data) . '}', $output);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
case 'comment':
|
case 'comment':
|
||||||
case 'file':
|
case 'file':
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue