protected function _injectScripts($id, $response)
{
if (strpos($response->type(), 'html') === false) {
return;
}
$body = $response->body();
if (!is_string($body)) {
return;
}
$pos = strrpos($body, '</body>');
if ($pos === false) {
return;
}
$url = Router::url('/', true);
$script = "<script id=\"__debug_kit\" data-id=\"{$id}\" data-url=\"{$url}\" src=\"" . Router::url('/debug_kit/js/toolbar.js') . '"></script>';
$body = substr($body, 0, $pos) . $script . substr($body, $pos);
$response->body($body);
}