Setup Router

@param Request $request

@return \Shade\App
512550
protected function setupRouter(Request $request)
    {
        if ($request instanceof Request\Web) {
            $router = $this->getRouter();
            if (
                $router instanceof Router\RouterCuInterface
                && $router->isRequestedUrlClean($request))
            {
                $router->enableCleanUrls();
            }
        }

        return $this;
    }
163800
public function matchRoute(Request $request)
    {
        $attributes = [];
        $route = $this->getRouteByPath($request->getPathInfo(), (new RequestContext())->fromRequest($request), $attributes);
        $request->attributes->add($attributes);
        $request->attributes->set('_route', $route);

        return new MatchedRoute($route, $attributes);
    }
362104
public function create(Request $request)
    {
        $view = parent::create($request);

        $view['layouts'] = Layouts::getLayouts('voyager-frontend');

        return $view;
    }
212230
public function switchAction(Request $request)
    {
        $domainConfiguration = $this->get('kunstmaan_admin.domain_configuration');
        $host = $request->query->get('host');
        $hosts = $domainConfiguration->getFullHostConfig();
        if (!array_key_exists($host, $hosts)) {
            throw $this->createNotFoundException('Invalid host specified');
        }

        $currentHost = $domainConfiguration->getHost();

        $session = $request->getSession();
        if ($request->get('from_url_chooser')) {
            $session->set(DomainConfiguration::SWITCH_HOST, $host);
        } else {
            $session->set(DomainConfiguration::OVERRIDE_HOST, $host);
        }

        /*
         * If current host type is different then the host going to, redirect to it's homepage.
         * If coming from url chooser, don't redirect to homepage if other host.
         */
        if ((($hosts[$host]['type'] !== $hosts[$currentHost]['type']) || (!$request->query->has('route'))) && (!$request->get('from_url_chooser'))) {
            $route = 'KunstmaanAdminBundle_homepage';
            $defaultLocale = $this->get('kunstmaan_admin.domain_configuration')->getDefaultLocale();
        } else {
            $route = $request->query->get('route');
            $routeParams = $request->query->get('route_params');
            $defaultLocale = $hosts[$host]['default_locale'];
        }

        $routeParams['_locale'] = $defaultLocale;

        $response = new RedirectResponse(
            $this->get('router')->generate($route, $routeParams)
        );

        return $response;
    }
1216095
public function route(Request $request)
    {
        $request->setUrl($this->api->getPath($request));

        $routeParameters = $this->getRoute($request);
        if ($routeParameters) {
            $class = $routeParameters['class'];
            $function = $routeParameters['function'];
            $routeClass = new $class($this->integration, $this->api, $request);

            return $routeClass->$function();
        } else {
            return $this->api->callAPI($request);
        }
    }
116616
public function route(Request $request)
    {
        if ($request instanceof Request\Web) {
            $server = $request->getServer();
            if (!isset($server['REQUEST_URI'])) {
                throw new Exception('REQUEST_URI is not set');
            }
            $this->logger->debug('Routing of web request', ['REQUEST_URI' => $server['REQUEST_URI']]);
            $urlComponents = explode('?', $server['REQUEST_URI']);
            $destination = reset($urlComponents);
            if (strpos($destination, $this->entryPoint) === 0) {
                $destination = substr($destination, strlen($server['SCRIPT_NAME']));
            }
        } elseif ($request instanceof Request\Cli) {
            $argv = $request->getArgv();
            $destination = isset($argv[1]) ? $argv[1] : '/';
            $this->logger->debug('Routing of CLI request', ['argv' => $argv]);
        } elseif ($request instanceof Request\Virtual) {
            $this->logger->debug(
                'Routing of virtual request',
                ['controller' => $request->getController(), 'action' => $request->getAction()]
            );
            return new Route($request->getController(), $request->getAction());
        } else {
            throw new Exception('Request type not supported');
        }

        $destination = trim($destination, '/');
        $destination = empty($destination) ? '/' : $destination;

        $this->logger->debug('Searching for corresponding route', ['destination' => $destination]);

        return $this->getRoute($destination);
    }
174505
protected function runRoute(Request $request, Route $route)
    {
        $request->setRouteResolver(function () use ($route) {
            return $route;
        });

        $this->events->dispatch(new Events\RouteMatched($route, $request));

        return $this->prepareResponse($request,
            $this->runRouteWithinStack($route, $request)
        );
    }
902752
public function route(Request $request)
    {
        foreach ($this->routes as $route) {
            if ($route->matches($request)) {
                return $route;
            }
        }

        return null;
    }
1316840
protected function doRequest($request)
    {
        $path = getcwd();
        if (defined('APP_PATH')) {
            $path = APP_PATH;
        }
        $loader = new ClassLoader();

        $loader->add(null, $path);
        $loader->register();

        // Create application
        Configuration::addPath($path . '/Configuration');
        Template::addPath($path . '/Views');

        $uri = str_replace('http://localhost/', '', $request->getUri());
        preg_match('/^([a-zA-Z0-9\/\-_]+).?([a-zA-Z0-9\-_]*)\??([a-zA-Z0-9\-_\=]*)/i', $uri, $matches);

        if (isset($matches[3]) && $matches[3] != '') {
            $params = parse_url($request->getUri());
            parse_str($params['query'], $_GET);
        }

        if (isset($matches[1]) && $matches[1] != '') {
            $_GET['url'] = $matches[1];
        }

        if (isset($matches[2]) && $matches[2] != '') {
            $_GET['extension'] = $matches[2];
        }

        $app = new Application();

        $zendRequest = $app->getRequest();
        $zendResponse = $app->getResponse();

        $uri = new HttpUri($request->getUri());
        $queryString = $uri->getQuery();
        $method = strtoupper($request->getMethod());

        if ($queryString) {
            parse_str($queryString, $query);
        }

        if ($method == HttpRequest::METHOD_POST) {
            $zendRequest->setPost(new Parameters($request->getParameters()));
        }
        /* elseif ($method == HttpRequest::METHOD_PUT) {
            $zendRequest->setContent($request->getContent());
        }*/

        $zendRequest->setMethod($method);
        $zendRequest->setUri($uri);

        // Application bootstrap
        $app->bootstrap();

        $app->run();


        return new Response(
            $zendResponse->getContent(),
            $zendResponse->getStatusCode(),
            $zendResponse->getHeaders()->toArray()
        );

    }
552579
protected function buildRequest()
    {
        $request = new Request($this->helper());
        $request->setRouter($this->router());

        return $request;
    }
587968
protected function handle(Request $request)
    {
        try {
            list($routeInformation, $parameters) = $this->findRoute($request);

            return (new Pipeline($this->container))
                ->through($routeInformation['middlewares'])
                ->send($request)
                ->then(function (Request $request) use ($routeInformation, $parameters) {
                    if ($routeInformation['action'] instanceof Closure) {
                        return call_user_func_array($routeInformation['action'], $parameters);
                    }

                    list($controller, $action) = $routeInformation['action'];
                    $controllerInstance = new $controller;

                    if ($controllerInstance instanceof KeeperBaseController) {
                        $controllerInstance->setContainer($this->container);
                        $controllerInstance->setRequest($request);
                    }

                    return call_user_func_array([$controllerInstance, $action], $parameters);
                });

        } catch (Throwable $exception) {
            if ($this->exceptionHandler) {
                return $this->exceptionHandler->handle($exception, $request);
            }

            return new Response((string)$exception, 500);
        }
    }
570123
public function boot(Request $request, Router $router)
    {
        $installer = new Installer\Installer();

        if (php_sapi_name() !== 'cli' && !$installer->isInstalled()) {
            if (!$this->app['migration.repository']->repositoryExists()) {
                $this->app['migration.repository']->createRepository();
            }

            $this->app['migrator']->run(base_path('/vendor/boomcms/boom-core/src/database/migrations'));

            $site = $installer->saveSiteDetails($request->input('site_name'), $request->input('site_email'));

            $router->setActiveSite($site);

            $name = $request->input('user_name');
            $email = $request->input('user_email');

            $person = $this->dispatch(new Jobs\CreatePerson($email, $name));

            $person->addSite($site);
            $person->setSuperuser(true);
            Person::save($person);

            auth()->login($person);

            $page = $this->dispatch(new Jobs\CreatePage());

            // Make the page visible so that it can be seen by the user after logging in
            $page->setVisibleAtAnyTime(true);
            PageFacade::save($page);

            $this->dispatch(new Jobs\CreatePagePrimaryUri($page, '', ''));
            $installer->markInstalled();

            header('Location: /boomcms/login');
            exit;
        }
    }
811459
public function bind(Request $request)
    {
        $this->compileRoute();

        $this->parameters = (new RouteParameterBinder($this))
                        ->parameters($request);

        $this->originalParameters = $this->parameters;

        return $this;
    }
974172
public function setRouteNameFromRequest(Request $request)
    {
        $routeName = $this->routeTranslator->getRouteNameFromPath(
            $request->getUri(), $this->getCurrentLocale()
        );

        $this->routeTranslator->setCurrentRoute($routeName);
    }
789377
protected function setRequestProperties(Request $request)
    {
        $this["basePath"] = $request->getBasePath();
        $this["baseUrl"] = $request->getSchemeAndHttpHost() . $this["basePath"];
    }
1340999
public function indexAction(Request $request)
    {
        // Special case, not correctly setup yet. Do so now.
        if (!$this->isInstalled()) {
            return new RedirectResponse($request->getUri() . 'install.html');
        }

        return new Response(
            str_replace(
                'var TENSIDEApi=window.location.href.split(\'#\')[0];',
                'var TENSIDEApi=\'' . $request->getSchemeAndHttpHost() . $request->getBaseUrl() . '/\';',
                file_get_contents($this->getAssetsDir() . '/index.html')
            ),
            200,
            [
                'Content-Type' => 'text/html; charset=UTF-8'
            ]
        );
    }
830939
public function setRequest(Request $request)
    {
        // reset the current state
        $this->reset();

        // retrieve a new session from the app
        $this->session = $this->app->make('session');

        return parent::setRequest($request);
    }