Configuration checks/tests route.

@param Request $request

@return \Bolt\Response\TemplateResponse
354129
public function checks(Request $request)
    {
        $defaults = [
            'pass' => ['php' => [], 'system' => []],
            'fail' => ['php' => [], 'system' => []],
        ];
        $checks = MutableBag::fromRecursive([
            'requirements'    => $defaults,
            'recommendations' => $defaults,
        ]);
        /** @var RequirementCollection $baseReqs */
        $baseReqs = $this->app['requirements'];

        foreach ($baseReqs->getRequirements() as $requirement) {
            $result = $requirement->isFulfilled() ? 'pass' : 'fail';
            if ($requirement instanceof PhpConfigRequirement) {
                $checks->get('requirements')->get($result)->get('php')->add($requirement);

                continue;
            }
            $checks->get('requirements')->get($result)->get('system')->add($requirement);
        }
        foreach ($baseReqs->getRecommendations() as $recommendation) {
            $result = $recommendation->isFulfilled() ? 'pass' : 'fail';
            if ($recommendation instanceof PhpConfigRequirement) {
                $checks->get('recommendations')->get($result)->get('php')->add($recommendation);

                continue;
            }
            $checks->get('recommendations')->get($result)->get('system')->add($recommendation);
        }
        $showAll = $request->query->getBoolean('all');

        return $this->render('@bolt/checks/checks.twig', ['checks' => $checks, 'show_all' => $showAll]);
    }
165824
public function match(Request $request)
    {
        try {
            return parent::match($request);
        } catch (NotFoundHttpException $e) {
            $route = $this->findMatchingWordpressPost();

            if ( ! is_null($route)) {
                return $route->bind($request);
            }

            throw $e;
        }
    }
683566
public function run(Request $request = null)
    {
        \ini_set('display_errors', $this->config['debug'] ? 1 : 0);
        \ini_set('display_startup_errors', $this->config['debug'] ? 1 : 0);

        \date_default_timezone_set($this->config['timezone']);

        // map all routes
        foreach ($this->routes as $r => &$x) {
            if (isset($x['controller'])) {

                $this->router->map($x['method'], $r, $x['action'], $x['controller']);

            } else foreach ($x as &$xx) {

                $this->router->map($xx['method'], $r, $xx['action'], $xx['controller']);

            }
        }


        // dispatch
        try {
            try {

                $this->router->dispatch(
                        $request === null ? Request::createFromGlobals() : $request,
                        new class(
                                (new MultiControllerFactory(...$this->controller_factories))->close(),
                                $this->endobox,
                                $this->logger,
                                $this->config['app-namespace']) extends ControllerFactoryDecorator {

                            private $endobox;
                            private $logger;
                            private $namespace;

                            public function __construct(
                                    ControllerFactory $factory,
                                    BoxFactory $endobox,
                                    Logger $logger,
                                    string $namespace) {

                                parent::__construct($factory);
                                $this->endobox = $endobox;
                                $this->logger = $logger;
                                $this->namespace = $namespace;
                            }

                            public function create(string $type) : ?Controller {
                                return parent::create('\\' . $this->namespace . '\\controllers\\' . $type)
                                        ->setBoxFactory($this->endobox)
                                        ->setLogger($this->logger);
                            }

                        });

            } catch (\Klein\Exceptions\UnhandledException $e) {
                // TODO fix this mess with the stack trace being part of the message
                throw new \RuntimeException(\sprintf("%s: %s\n<pre>%s</pre>",
                        \get_class($e), $e->getMessage(), $e->getTraceAsString()), $e->getCode(), $e);
            }
        } catch (\Exception $e) {
            if ($this->config['catch-exceptions'] === false) {
                throw $e;
            }

            if ($this->config['debug'] === true) {
                die(self::formatException($e));
            }
            die();
        }

        return $this;
    }
340883
private function buildConfig(Request $request)
    {
        $config = array(
            'mode' => $request->query->get('mode', 'browse'),
        );
        if (null !== $types = $request->query->get('types', array())) {
            // TODO validate types
            $config['types'] = $types;
        }
        return $config;
    }
268537
public function initAction(Request $request)
    {
        $form = $this->container->get('form.factory')->createNamed(
            'skeleton',
            GlobalCreationType::class,
            null,
            array(
                'action' => $this->container->get('router')->generate('synapse_admin_skeleton_init'),
                'method' => 'POST',
                'csrf_protection' => false,
            )
        );
        if ($request->request->has('skeleton')) {
            $form->handleRequest($request);
            if ($form->isValid()) {
                return $this->redirect(
                    $this->container->get('router')->generate(
                        'synapse_admin_skeleton_edition',
                        array('id' => $form->getData()->getId())
                    )
                );
            }
        }

        return $this->render('SynapseAdminBundle:Skeleton:create.html.twig', array(
            'form' => $form->createView(),
        ));
    }
974870
public function run(Request $request)
    {
        $this->container = $this->container ?: new Container;
        
        try {
            if (! is_string($this->action['uses'])) {
                return $this->runCallable($request);
            }
            
            list($class, $method) = explode('@', $this->action['uses']);
            $cl = new ClassLoader;
            $cl->addPsr4($this->getAppNamespace(), app('path'));
            $file = $cl->findFile($class);
            $cmd = 'php -l ' . $file;
            
            if (strpos(exec($cmd, $output), 'No syntax errors detected') === false) {
                $route = array_get($this->action, 'as', $this->action['uses']);
                $error = head(array_filter($output));
                
                throw new SyntaxErrorException($route, $error);
            }
            
            set_error_handler([$this, 'error']);
            
            if ($this->customDispatcherIsBound()) {
                return $this->runWithCustomDispatcher($request);
            }
            
            return $this->runController($request);
        } catch (HttpResponseException $e) {
            return $e->getResponse();
        }
    }
920059
protected function getConfiguration(Request $request = null)
    {
        if (!$this->configuration) {
            if (!$request) {
                throw new \RuntimeException('The first time getConfiguration() is called, you must pass a Request.');
            }

            $this->configuration = new Configuration($request);
            $this->configure($request, $this->configuration);
            $this->configuration->validate();
        }

        return $this->configuration;
    }
78876
public function index($request)
    {
        $suite = 'check';

        if ($name = $request->param('Suite')) {
            $suite = $name;
        }

        $checker = new EnvironmentChecker($suite, 'Environment status');
        $checker->setRequest($request);
        $checker->init($this->config()->permission);

        return $checker;
    }
908012
public function execute (Request $request)
		{
			foreach ($this->routes as $route) {
				if ($route->isValid($request)) {
					return $route->execute($request);
				}
			}

			throw new NoMatchingRouteException('No matching route found.');
		}
1143822
public function resourceByRequest(Request $request)
    {

        $routeName = $this->getRouteName($request);

        if (isset($this->routeMap[$routeName])) {
            return $this->routeMap[$routeName];
        }

        $this->routeMap[$routeName] = $this->calculateResourceName($routeName);

        return $this->routeMap[$routeName];

    }
123997
public function handle(Request $request): Response
    {
        try {
            $matcher = $this->getUrlMatcher($request);

            $parameters = $matcher->match($request->getPathInfo());

            if (empty($parameters['_controller'])) {
                throw new InvalidRouteException('Route requires a _controller callable');
            }

            if (!\is_callable($parameters['_controller'])) {
                throw new InvalidRouteException('_controller must be a callable');
            }

            $callback = $parameters['_controller'];

            $result = call_user_func_array($callback, $this->getControllerParameters($request, $parameters));

            if (!$result instanceof Response) {
                throw new InvalidResponseException('Response must be an instance of \Symfony\Component\HttpFoundation\Response');
            }
        } catch (\Exception $e) {
            $result = $this->handleException($request, $e);
        }

        return $result;
    }
874128
protected function doRequest(Request $request)
    {

        $this->client->send($request, $response = new Response());

        return $response;
    }
942339
public function listAction(Request $request)
    {
        /** @var ConfiguratorFactory $configuratorFactory */
        $configuratorFactory = $this->getConfiguratorFactory($this->getClassName());
        /** @var CrudConfigurator $crudConfigurator */
        $crudConfigurator = $configuratorFactory->getConfigurator(CrudConfigurator::class);

        $this->isGrantedOr404Error($crudConfigurator, Constants::ACTION_READ);

        /** @var GridConfigurator $gridConfigurator */
        $gridConfigurator = $configuratorFactory->getConfigurator(GridConfigurator::class);
        /* @var PageConfigurator $pageConfigurator */
        $pageConfigurator = $configuratorFactory->getConfigurator(PageConfigurator::class);

        $translator = $this->get('translator');
        $translationDomain = $this->getParameter('symfonyid.admin.translation_domain');

        $template = $crudConfigurator->getTemplate();
        $listTemplate = $request->isXmlHttpRequest() ? $template->getAjaxTemplate() : $template->getList();

        $reflectionModel = new \ReflectionClass($crudConfigurator->getCrud()->getModelClass());
        $filters = $gridConfigurator->getFilters($reflectionModel);

        /** @var View $view */
        $view = $this->get('symfonyid.admin.view.view');
        $view->setParam('page_title', $translator->trans($pageConfigurator->getTitle(), array(), $translationDomain));
        $view->setParam('page_description', $translator->trans($pageConfigurator->getDescription(), array(), $translationDomain));

        /*
         * Translate tentity fields
         */
        $view->setParam('filter_fields', implode(', ', array_map(function ($value) use ($translator, $translationDomain) {
            return $translator->trans(sprintf('entity.fields.%s', $value), array(), $translationDomain);
        }, $filters)));
        $view->setParam('filter_fields_entity', implode(', ', $filters));

        return $this->doList($request, $crudConfigurator, $view, $gridConfigurator->getColumns($reflectionModel), $listTemplate, $gridConfigurator->getGrid()->isFormatNumber());
    }
157154
public function match( Request $request )
	{
		$routes = $this->get( $request->getMethod() );

		// First, we will see if we can find a matching route for this current request
		// method. If we can, great, we can just return it so that it can be called
		// by the consumer. Otherwise we will check for routes with another verb.
		$route = $this->check( $routes, $request );

		if ( !is_null( $route ) )
		{
			return $route->bind( $request );
		}

		// If no route was found we will now check if a matching route is specified by
		// another HTTP verb. If it is we will need to throw a MethodNotAllowed and
		// inform the user agent of which HTTP verb it should use for this route.
		$others = $this->checkForAlternateVerbs( $request );

		if ( count( $others ) > 0 )
		{
			return $this->getRouteForMethods( $request, $others );
		}

		throw new NotFoundHttpException;
	}
1287452
public function getMatchingRoute($request)
    {
        // Get matching route
        $this->currentRoute = $route = $this->routes->match($request);

        return $route;
    }
435701
public function match(Request $request)
    {
        $hasWpParams = $request->path() == '/' && ($request->has('p') || $request->has('post_id'));

        if ($hasWpParams && $route = $this->findMatchingWordPressPost($request)) {
            return $route;
        }

        try {
            return parent::match($request);
        } catch (NotFoundHttpException $e) {

            if ($route = $this->findMatchingWordPressPost($request)) {
                return $route;
            }

            throw $e;
        }
    }
727446
public function check(Request $request)
    {
        $request->validate(['code' => 'required|numeric']);

        if (Hash::check($request->code, $this->getHash())) {
            session(['can_visit' => true]);

            return response([
                'status' => 'success',
            ]);
        }

        $this->incrementLoginAttempts($request);

        if ($this->hasTooManyLoginAttempts($request) && $this->throttleIsActive()) {
            return response([
                'too_many_attempts' => true,
                'seconds_message'  => TransFormer::transform($this->getBlockedSeconds($request), $this->config['seconds_message']),
            ], 401);
        }

        return response([
            'too_many_attempts' => false,
            'attempts_left'    => $this->showAttempts($request),
        ], 401);
    }