Barryvdh\Debugbar\LaravelDebugbar::injectDebugbar PHP Метод

injectDebugbar() публичный Метод

Injects the web debug toolbar into the given Response.
public injectDebugbar ( Response $response )
$response Symfony\Component\HttpFoundation\Response A Response instance Based on https://github.com/symfony/WebProfilerBundle/blob/master/EventListener/WebDebugToolbarListener.php
    public function injectDebugbar(Response $response)
    {
        $content = $response->getContent();
        $renderer = $this->getJavascriptRenderer();
        if ($this->getStorage()) {
            $openHandlerUrl = route('debugbar.openhandler');
            $renderer->setOpenHandlerUrl($openHandlerUrl);
        }
        $renderedContent = $renderer->renderHead() . $renderer->render();
        $pos = strripos($content, '</body>');
        if (false !== $pos) {
            $content = substr($content, 0, $pos) . $renderedContent . substr($content, $pos);
        } else {
            $content = $content . $renderedContent;
        }
        // Update the new content and reset the content length
        $response->setContent($content);
        $response->headers->remove('Content-Length');
    }

Usage Example

Пример #1
0
 /**
  * Injects the web debug toolbar into the given Response.
  *
  * @param \Symfony\Component\HttpFoundation\Response $response A Response instance
  * Based on https://github.com/symfony/WebProfilerBundle/blob/master/EventListener/WebDebugToolbarListener.php
  * @static 
  */
 public static function injectDebugbar($response)
 {
     return \Barryvdh\Debugbar\LaravelDebugbar::injectDebugbar($response);
 }