public function getWidgets()
 {
     $name = $this->getName();
     $data = parent::getWidgets();
     $data['currentroute'] = array('icon' => 'share', 'tooltip' => 'Route', 'map' => "{$name}.uri", 'default' => '{}');
     return $data;
 }
Ejemplo n.º 2
0
 /**
  * Modify the response and inject the debugbar (or data in headers)
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Symfony\Component\HttpFoundation\Response  $response
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function modifyResponse($request, $response)
 {
     $app = $this->app;
     if ($app->runningInConsole() or !$this->isEnabled() || $this->isDebugbarRequest()) {
         return $response;
     }
     if ($this->shouldCollect('config', false)) {
         try {
             $configCollector = new ConfigCollector();
             $configCollector->setData($app['config']->getItems());
             $this->addCollector($configCollector);
         } catch (\Exception $e) {
             $this->addException(new Exception('Cannot add ConfigCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     /** @var \Illuminate\Session\SessionManager $sessionManager */
     $sessionManager = $app['session'];
     $httpDriver = new SymfonyHttpDriver($sessionManager, $response);
     $this->setHttpDriver($httpDriver);
     if ($this->shouldCollect('symfony_request', true) and !$this->hasCollector('request')) {
         try {
             $this->addCollector(new SymfonyRequestCollector($request, $response, $sessionManager));
         } catch (\Exception $e) {
             $this->addException(new Exception('Cannot add SymfonyRequestCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     if ($response->isRedirection()) {
         try {
             $this->stackData();
         } catch (\Exception $e) {
             $app['log']->error('Debugbar exception: ' . $e->getMessage());
         }
     } elseif ($request->isXmlHttpRequest() || $request->wantsJson() and $app['config']->get('laravel-debugbar::config.capture_ajax', true)) {
         try {
             $this->sendDataInHeaders(true);
         } catch (\Exception $e) {
             $app['log']->error('Debugbar exception: ' . $e->getMessage());
         }
     } elseif ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html') || 'html' !== $request->format()) {
         //Do nothing
     } elseif ($app['config']->get('laravel-debugbar::config.inject', true)) {
         try {
             $this->injectDebugbar($response);
         } catch (\Exception $e) {
             $app['log']->error('Debugbar exception: ' . $e->getMessage());
         }
     }
     // Stop further rendering (on subrequests etc)
     $this->disable();
     return $response;
 }
 /**
  * Modify the response and inject the debugbar (or data in headers)
  *
  * @param  \Symfony\Component\HttpFoundation\Request $request
  * @param  \Symfony\Component\HttpFoundation\Response $response
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function modifyResponse(Request $request, Response $response)
 {
     $app = $this->app;
     if ($app->runningInConsole() || !$this->isEnabled() || $this->isDebugbarRequest()) {
         return $response;
     }
     if ($this->shouldCollect('config', false)) {
         try {
             $configCollector = new ConfigCollector();
             $configCollector->setData($app['config']->all());
             $this->addCollector($configCollector);
         } catch (\Exception $e) {
             $this->addException(new Exception('Cannot add ConfigCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     /** @var \Illuminate\Session\SessionManager $sessionManager */
     $sessionManager = $app['session'];
     $httpDriver = new SymfonyHttpDriver($sessionManager, $response);
     $this->setHttpDriver($httpDriver);
     if ($this->shouldCollect('session')) {
         try {
             $this->addCollector(new SessionCollector($sessionManager));
         } catch (\Exception $e) {
             $this->addException(new Exception('Cannot add SessionCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     if ($this->shouldCollect('symfony_request', true) && !$this->hasCollector('request')) {
         try {
             $this->addCollector(new SymfonyRequestCollector($request, $response, $sessionManager));
         } catch (\Exception $e) {
             $this->addException(new Exception('Cannot add SymfonyRequestCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
     }
     if ($app['config']->get('debugbar.clockwork')) {
         try {
             $this->addCollector(new ClockworkCollector($request, $response, $sessionManager));
         } catch (\Exception $e) {
             $this->addException(new Exception('Cannot add ClockworkCollector to Laravel Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
         }
         $this->addClockworkHeaders($response);
     }
     if ($response->isRedirection()) {
         try {
             $this->stackData();
         } catch (\Exception $e) {
             $app['log']->error('Debugbar exception: ' . $e->getMessage());
         }
     } elseif ($this->isJsonRequest($request) && $app['config']->get('debugbar.capture_ajax', true)) {
         try {
             $this->sendDataInHeaders(true);
         } catch (\Exception $e) {
             $app['log']->error('Debugbar exception: ' . $e->getMessage());
         }
     } elseif ($response->headers->has('Content-Type') && strpos($response->headers->get('Content-Type'), 'html') === false || $request->getRequestFormat() !== 'html') {
         try {
             // Just collect + store data, don't inject it.
             $this->collect();
         } catch (\Exception $e) {
             $app['log']->error('Debugbar exception: ' . $e->getMessage());
         }
     } elseif ($app['config']->get('debugbar.inject', true)) {
         try {
             $this->injectDebugbar($response);
         } catch (\Exception $e) {
             $app['log']->error('Debugbar exception: ' . $e->getMessage());
         }
     }
     // Stop further rendering (on subrequests etc)
     $this->disable();
     return $response;
 }
 public function testName()
 {
     $c = new ConfigCollector(array(), 'foo');
     $this->assertEquals('foo', $c->getName());
     $this->assertArrayHasKey('foo', $c->getWidgets());
 }