Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener::injectToolbar PHP Method

injectToolbar() protected method

Injects the web debug toolbar into the given Response.
protected injectToolbar ( Response $response )
$response Symfony\Component\HttpFoundation\Response A Response instance
    protected function injectToolbar(Response $response)
    {
        if (function_exists('mb_stripos')) {
            $posrFunction = 'mb_strripos';
            $substrFunction = 'mb_substr';
        } else {
            $posrFunction = 'strripos';
            $substrFunction = 'substr';
        }

        $content = $response->getContent();

        if (false !== $pos = $posrFunction($content, '</body>')) {
            $toolbar = "\n".str_replace("\n", '', $this->templating->render(
                'WebProfilerBundle:Profiler:toolbar_js.html.twig',
                array('token' => $response->headers->get('X-Debug-Token'))
            ))."\n";
            $content = $substrFunction($content, 0, $pos).$toolbar.$substrFunction($content, $pos);
            $response->setContent($content);
        }
    }