Snowair\Debugbar\ServiceProvider::safeCheck PHP Метод

safeCheck() защищенный Метод

protected safeCheck ( )
    protected function safeCheck()
    {
        $config = $this->di['config.debugbar'];
        $router = $this->di['router'];
        $debugbar = $this->di['debugbar'];
        if ($config->get('enabled')) {
            $white_lists = (array) $config->get('white_lists');
            if (!empty($white_lists) && !in_array($this->di['request']->getClientAddress(true), $white_lists)) {
                $debugbar->disable();
                return;
            }
            $router->handle();
            $deny_routes = (array) $config->get('deny_routes');
            $allow_routes = (array) $config->get('allow_routes');
            $current = $router->getMatchedRoute();
            if (is_object($current)) {
                $current = $current->getName();
                if (strpos($current, 'debugbar') === 0) {
                    $app = $this->di['app'];
                    if (method_exists($app, 'useImplicitView')) {
                        $app->useImplicitView(false);
                    }
                    $debugbar->isDebugbarRequest = true;
                    $debugbar->debugbarRequestCollector();
                    $debugbar->disable();
                    return;
                }
                if (!empty($allow_routes) && !in_array($current, $allow_routes)) {
                    $debugbar->disable();
                    return;
                }
                if (!empty($deny_routes) && in_array($current, $deny_routes)) {
                    $debugbar->disable();
                    return;
                }
            }
            return;
        }
    }