protected function write(array $record)
 {
     if (!$this->debugBar->hasCollector('messages')) {
         return;
     }
     $this->debugBar["messages"]->addMessage($record['formatted'], $record['level_name']);
 }
 public function onKernelResponse(FilterResponseEvent $event)
 {
     $request = $event->getRequest();
     if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
         return;
     }
     $response = $event->getResponse();
     if ($request->isXmlHttpRequest()) {
         $this->debugbar->sendDataInHeaders();
         return;
     }
     //        if ($response->isRedirection()
     //            OR !$response->headers->has('content-type')
     //            OR false === strpos($response->headers->get('content-type'), 'text/html')
     //        ) {
     //            if ($this->debugbar->hasStackedData()) {
     //                //esto es para que solo guarde la ultima
     //                $this->debugbar->getStackedData();
     //            }
     //            $this->debugbar->stackData();
     //
     //            return;
     //        }
     $base = $request->getBasePath() . '/debugbar/';
     $debugbarRenderer = $this->debugbar->getJavascriptRenderer($base);
     $this->injectScripts($response, $debugbarRenderer);
 }
Beispiel #3
0
 /**
  * @param DebugBar|null $debugBar
  * @param Config|null $config
  * @return $this
  */
 public function addConfig(DebugBar $debugBar = null, Config $config = null)
 {
     if (null === $debugBar) {
         return $this;
     }
     $debugBar->addCollector(new \DebugBar\DataCollector\ConfigCollector($config->all()));
     return $this;
 }
 /**
  * @param Client $client
  * @param DebugBar $debugBar
  */
 private function registerDebugbarSubscriber(Client $client, DebugBar $debugBar)
 {
     /** @var TimeDataCollector $timeline */
     $timeline = $debugBar->getCollector('time');
     /** @var ExceptionsCollector $exceptions */
     $exceptions = $debugBar->getCollector('exceptions');
     // Attach event subscribers.
     $client->getEmitter()->attach(new DebugbarSubscriber($timeline, $exceptions));
 }
 /**
  * @param AdapterInterface $adapter
  * @param DebugBar $debugbar
  */
 protected function prepareDbAdapter(AdapterInterface $adapter, DebugBar $debugbar)
 {
     $driver = $adapter->getDriver();
     if ($driver instanceof Pdo) {
         $pdo = $driver->getConnection()->getResource();
         $traceablePdo = new TraceablePDO($pdo);
         $pdoCollector = new PDOCollector($traceablePdo);
         $debugbar->addCollector($pdoCollector);
     }
 }
 protected function renderBar($result)
 {
     if (strpos($result, '</head>') === false || strpos($result, '</body>') === false) {
         return $result;
     }
     $includes = $this->debugBarRenderer->renderHead();
     $this->debugBar->collect();
     $toolbar = $this->debugBarRenderer->render();
     $result = $this->insertAt($result, strpos($result, '</head>'), $includes);
     return $this->insertAt($result, strpos($result, '</body>'), $toolbar);
 }
Beispiel #7
0
 public function open_handler()
 {
     $this->config->load('profiler', true);
     $path = $this->config->item('cache_path', 'profiler');
     $debugbar = new DebugBar();
     $debugbar->setStorage(new FileStorage($path));
     $openHandler = new OpenHandler($debugbar);
     $data = $openHandler->handle(NULL, FALSE, FALSE);
     $this->output->enable_profiler(FALSE);
     $this->output->set_content_type('json');
     $this->output->set_output($data);
 }
Beispiel #8
0
 /**
  * @param DebugBar|null $debugBar
  * @param Fdb|null $fdb
  * @return $this
  * @throws \DebugBar\DebugBarException
  */
 public function addFdb(DebugBar $debugBar = null, Fdb $fdb = null)
 {
     if (null === $debugBar) {
         return $this;
     }
     $fdb->createPool();
     $collections = new PDOCollector();
     foreach ($fdb as $name => $driverInterface) {
         $traceablePDO = new TraceablePDO($driverInterface->getPdo());
         $collections->addConnection($traceablePDO, $name);
     }
     $debugBar->addCollector($collections);
     return $this;
 }
Beispiel #9
0
 /**
  * {@inheritdoc}
  */
 public function getCurrentRequestId()
 {
     if ($this->requestId == null) {
         $this->requestId = sha1(parent::getCurrentRequestId());
     }
     return $this->requestId;
 }
Beispiel #10
0
 /**
  * Twig::render()
  * 
  * @param mixed $name
  * @param mixed $vars_array
  */
 public function render($name, $vars_array = array())
 {
     if (DEBUGING === true) {
         $debugBar = new DebugBar();
         $debugBar->addCollector(new MessagesCollector());
         $debugBar->addCollector(new ConfigCollector(Config::get()));
         $doctrine = Config::get('doctrine');
         if ($doctrine) {
             $debugBar->addCollector(new DoctrineCollector($doctrine));
         }
         $debugBar->addCollector(new TimeDataCollector());
         $debugBar->addCollector(new RequestDataCollector());
         $debugBar->addCollector(new MemoryCollector());
     }
     $twig = $this->getInstance();
     $content = $twig->loadTemplate($name . '.html.twig');
     if (DEBUGING === true) {
         $debugBarRender = $debugBar->getJavascriptRenderer();
         $bar['bar']['head'] = $debugBarRender->renderHead();
         $bar['bar']['body'] = $debugBarRender->render();
         $vars_array = array_merge($vars_array, $bar);
     }
     $args = array_merge($this->getGlobalArgs(), $vars_array);
     echo $content->render($args);
 }
Beispiel #11
0
 /**
  * Construct object
  */
 public function __construct()
 {
     $this->debugBar = new BaseDebugBar();
     $this->debugBar->addCollector(new PhpInfoCollector());
     $this->debugBar->addCollector(new MessagesCollector());
     $this->debugBar->addCollector(new RequestDataCollector());
     $this->debugBar->addCollector(new UrlRewriterDataCollector());
     $this->debugBar->addCollector(new TimeDataCollector());
     $this->debugBar->addCollector(new MemoryCollector());
     $this->debugBar->addCollector(new ExceptionsCollector());
 }
 /**
  * Set storage for debugbar
  * 
  * @return boolean
  */
 protected function setStorage()
 {
     if (!isset($this->config['open_handler_url'])) {
         return false;
     }
     $path = $this->config['cache_path'];
     $cache_path = $path === '' ? APPPATH . 'cache/debugbar/' : $path;
     file_exists($cache_path) or mkdir($cache_path, DIR_WRITE_MODE, true);
     $this->debugbar->setStorage(new FileStorage($cache_path));
     return true;
 }
Beispiel #13
0
 /**
  * Add current smarty settings to the log.
  */
 public function addSmarty()
 {
     $vars = template\HtmlTemplate::getInstance()->getTemplateVars();
     foreach ($vars as &$var) {
         if ($var === '') {
             $var = '(empty)';
         } elseif ($var === false) {
             $var = '(bool: false)';
         } elseif ($var === true) {
             $var = '(bool: true)';
         } elseif ($var === null) {
             $var = '(nil)';
         }
     }
     ksort($vars);
     $this->debugBar->addCollector(new Collector\ConfigCollector($vars, 'Smarty'));
 }
 /**
  * @param DebugBar $debugbar
  */
 protected function selectStorage(DebugBar $debugbar)
 {
     $config = $this->app['config'];
     if ($config->get('debugbar.storage.enabled')) {
         $driver = $config->get('debugbar.storage.driver', 'file');
         switch ($driver) {
             case 'pdo':
                 $connection = $config->get('debugbar.storage.connection');
                 $table = $this->app['db']->getTablePrefix() . 'phpdebugbar';
                 $pdo = $this->app['db']->connection($connection)->getPdo();
                 $storage = new PdoStorage($pdo, $table);
                 break;
             case 'redis':
                 $connection = $config->get('debugbar.storage.connection');
                 $storage = new RedisStorage($this->app['redis']->connection($connection));
                 break;
             case 'file':
             default:
                 $path = $config->get('debugbar.storage.path');
                 $storage = new FilesystemStorage($this->app['files'], $path);
                 break;
         }
         $debugbar->setStorage($storage);
     }
 }
 /**
  * @param DebugBar $debugbar
  */
 protected function selectStorage(DebugBar $debugbar)
 {
     $config = $this->config;
     if ($config->storage->enabled) {
         $driver = $config->storage->get('driver', 'file');
         switch ($driver) {
             //TODO:: other driver
             default:
                 $path = $config->storage->path;
                 $storage = new FilesystemStorage($path);
                 break;
         }
         $debugbar->setStorage($storage);
     }
 }
 /**
  * @param DebugBar $debugbar
  */
 protected function selectStorage(DebugBar $debugbar)
 {
     $config = $this->config;
     if ($config->storage->enabled) {
         $driver = $config->storage->get('driver', 'file');
         switch ($driver) {
             case 'mongodb':
                 $connection = $config->storage->mongodb->connection;
                 $db = $config->storage->mongodb->db;
                 $options = $config->storage->mongodb->options;
                 $collection = $config->storage->mongodb->collection;
                 $storage = new MongoDB($connection, $db, $collection, $options);
                 break;
             default:
                 $path = $config->storage->path;
                 $storage = new Filesystem($path);
                 break;
         }
         $debugbar->setStorage($storage);
     }
 }
 public function init($initialiser = null)
 {
     $toolbarConfig = $this->config("bundl\\debugtoolbar");
     $baseUrl = $toolbarConfig->getStr("base_url", '/_debugbar');
     if (starts_with($baseUrl, '/')) {
         $passthroughs = $this->config("dispatch")->getArr("passthrough");
         if (!isset($passthroughs[substr($baseUrl, 1)])) {
             throw new \Exception("Please add the following to your defaults.ini within [dispatch]\n" . "passthrough[" . substr($baseUrl, 1) . "] = " . "../vendor/maximebf/debugbar/src/DebugBar/Resources");
         }
     }
     EventManager::listen(EventManager::CUBEX_WEBPAGE_RENDER_BODY, [$this, "renderBody"]);
     EventManager::listen(EventManager::CUBEX_WEBPAGE_RENDER_HEAD, [$this, "renderHead"]);
     EventManager::listen(EventManager::CUBEX_LOG, [$this, "catchLog"]);
     $this->_debugBar = new DebugBar();
     $this->_debugBar->addCollector(new PhpInfoCollector());
     $this->_debugBar->addCollector(new MessagesCollector());
     $this->_debugBar->addCollector(new TranslationDataCollector());
     $this->_debugBar->addCollector(new RequestDataCollector());
     $this->_debugBar->addCollector(new CubexCoreTimeData());
     $this->_debugBar->addCollector(new CassandraDataCollector());
     $this->_debugBar->addCollector(new QueryDataCollector());
     $this->_debugBar->addCollector(new MemoryCollector());
     $this->_debugBar->addCollector(new ExceptionsCollector());
     $this->_debugRender = $this->_debugBar->getJavascriptRenderer();
     $this->_debugRender->setBaseUrl($baseUrl);
 }