DebugKit\Routing\Filter\DebugBarFilter::_injectScripts PHP Метод

_injectScripts() защищенный Метод

The toolbar will only be injected if the response's content type contains HTML and there is a tag.
protected _injectScripts ( string $id, Response $response ) : void
$id string ID to fetch data from.
$response Cake\Network\Response The response to augment.
Результат void
    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);
    }