Snowair\Debugbar\PhalconDebugbar::boot PHP Method

boot() public method

启动debugbar: 设置collector
public boot ( )
    public function boot()
    {
        if (!$this->isEnabled()) {
            return;
        }
        $debugbar = $this;
        if (!$this->isDataPersisted()) {
            $this->selectStorage($debugbar);
            // for normal request and debugbar request both
        }
        if ($this->booted) {
            return;
        }
        $this->booted = true;
        if (isset($_REQUEST['_url']) and $_REQUEST['_url'] == '/favicon.ico' || isset($_SERVER['REQUEST_URI']) and $_SERVER['REQUEST_URI'] == '/favicon.ico' || !$this->isEnabled()) {
            return;
        }
        // only for normal request
        if ($this->shouldCollect('phpinfo', true)) {
            $this->addCollector(new PhpInfoCollector());
        }
        if ($this->shouldCollect('messages', true)) {
            $this->addCollector(new MessagesCollector());
        }
        if ($this->shouldCollect('memory', true)) {
            $this->addCollector(new MemoryCollector());
        }
        if ($this->shouldCollect('default_request', false)) {
            $this->addCollector(new RequestDataCollector());
        }
        if ($this->shouldCollect('exceptions', true)) {
            try {
                $exceptionCollector = new ExceptionsCollector();
                $exceptionCollector->setChainExceptions($this->config->options->exceptions->get('chain', true));
                $this->addCollector($exceptionCollector);
            } catch (\Exception $e) {
                $this->addException($e);
            }
        }
        if ($this->shouldCollect('time', true)) {
            if (defined('PHALCON_START')) {
                $startTime = PHALCON_START;
            } else {
                $startTime = isset($_SERVER["REQUEST_TIME_FLOAT"]) ? $_SERVER["REQUEST_TIME_FLOAT"] : $_SERVER["REQUEST_TIME"];
            }
            $this->addCollector(new TimeDataCollector($startTime));
        }
        if ($this->shouldCollect('route') && $this->di->has('router') && $this->di->has('dispatcher')) {
            try {
                $this->addCollector(new RouteCollector($this->di));
            } catch (\Exception $e) {
                $this->addException(new Exception('Cannot add RouteCollector to Phalcon Debugbar: ' . $e->getMessage(), $e->getCode(), $e));
            }
        }
        if ($this->shouldCollect('log', false) && $this->di->has('log')) {
            $this->addCollector(new LogsCollector($this->di, $this->config->options->log->get('aggregate', false), $this->config->options->log->get('formatter', 'line')));
        }
        $this->attachServices();
        $renderer = $this->getJavascriptRenderer();
        $renderer->setIncludeVendors($this->config->get('include_vendors', true));
        $renderer->setBindAjaxHandlerToXHR($this->config->get('capture_ajax', true));
    }