Set route lang attribute to all route request.

@param  Request $request
@return void
509253
public static function setLangAttribute($request)
    {
        // language may be present in url without {param} defined
        $languageSlug= self::setFromURL($request);
        if(!$languageSlug) {
            $languageSlug = App::getLocale();
        }

        //add lang parameter to every route/action request if user is accessing a language that's different than default
        if(config('project.multilanguage')) {
            // hide slug on default language in frontend
            //backend
            if (!isInAdmin()) {
                if (config('project.hideDefaultLanguageInURL') && $languageSlug ==  Language::getDefault('slug')) {
                    $languageSlug = '';
                }
            }

            URL::defaults(['lang' => $languageSlug]);
        }

        return;
    }
192917
protected function enterRequestScope($lang)
    {
        $requestStack = $this->container->get('request_stack');
        // If there already is a request, get the locale from it.
        if ($requestStack->getCurrentRequest()) {
            $locale = $requestStack->getCurrentRequest()->getLocale();
        }
        // If we don't have a request or the current request locale is different from the node langauge
        if (!$requestStack->getCurrentRequest() || ($locale && $locale !== $lang)) {
            $request = new Request();
            $request->setLocale($lang);

            $context = $this->container->get('router')->getContext();
            $context->setParameter('_locale', $lang);

            $requestStack->push($request);
        }
    }
1166299
private function parseAcceptLanguage(Request $request)
    {
        $locales = [];
        $acceptLanguage = trim($request->headers->get('Accept-Language'));

        if (!empty($acceptLanguage)) {
            $locales = array_map(function (AcceptLanguage $acceptLanguage) {
                return $acceptLanguage->getType();
            }, $this->localeNegotiator->parse($acceptLanguage));
        }

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

        $this->routeTranslator->setCurrentRoute($routeName);
    }
688871
private function getLanguage(Request $request)
    {
        $locale = $this->getRequestParameter($request, 'locale', false, null);

        if ($locale) {
            return $locale;
        }

        return $this->getRequestParameter($request, 'language', true);
    }
303854
public function setRequest(SimplifiedRequest $request)
    {
        if (!$this->element) {
            $this->setMatchElement($request->pathinfo);
        }

        parent::setRequest($request);
    }
396922
public function putLanguageAction(Request $request)
    {
        $user = $this->tokenStorage->getToken()->getUser();
        $user->setLocale($request->get('locale'));

        $this->objectManager->flush();

        return $this->viewHandler->handle(View::create(['locale' => $user->getLocale()]));
    }
878373
private function getLocale(Request $request)
    {
        $uri = $request->getRequestUri();

        foreach ($this->locales as $locale) {
            if (false !== strpos($uri, '/'.$locale.'/')) {
                return $locale;
            }
        }

        return $this->defaultLocale;
    }
255657
private function setTrustedProxyIpAddressesToTheCallingIp(Request $request)
    {
        $request->setTrustedProxies([$request->server->get('REMOTE_ADDR')], $this->getTrustedHeaderNames());
    }
523052
private function modifySlugs(Request &$request): void
    {
        $translations = $request->input('translations', []);
        $existingSlugs = [];
        $i = 1;

        foreach ($translations as $iso => $translationData) {
            // Auto generated
            if (!$slug = array_get($translationData, 'slug')) {
                continue;
            }

            $slug = SlugService::createSlug(CategoryTranslation::class, 'slug', $slug, ['unique' => false]);

            // Prevent equal slug's on create.
            if (in_array($slug, $existingSlugs)) {
                $slug .= '-' . $i;
                $i++;
            }

            $translations[$iso]['slug'] = $slug;
            $existingSlugs[] = $slug;
        }

        $request->merge(compact('translations'));
    }
664868
public function route(Request $request) {
        $httpMethod = $request->getMethod();

        if ($httpMethod === 'BREW') {
            throw new RuntimeException('I\'m a teapot!', 418);
        }

        if (!isset(self::$supportedHttpMethods[$httpMethod])) {
            throw new RuntimeException('Unsupported HTTP method: ' . $httpMethod, 501);
        }

        $path = $request->getPathInfo();
        $matches = [];

        foreach ($this->routes as $resourceName => $route) {
            if (preg_match($route, $path, $matches)) {
                break;
            }
        }

        // Path matched no route
        if (!$matches) {
            throw new RuntimeException('Not Found', 404);
        }

        // Create and populate a route instance that we want to inject into the request
        $route = new Route();
        $route->setName($resourceName);

        // Inject all matches into the route as parameters
        foreach ($matches as $key => $value) {
            if (is_string($key)) {
                $route->set($key, $value);
            }
        }

        // Store the route in the request
        $request->setRoute($route);
    }
505894
public function setRouter($request)
    {
        $this->container->set('request', $request);
        $this->container->make(\Cygnite\Router\Router::class);
        $this->container->get('router')->setRequest($request);
        $this->router = $this->container->get('router');
    }
1168614
private function getTranslatedUrl(Request $request)
    {
        /** @var Route $route */
        $route = $request->route();

        if ( ! ($route instanceof Route) || is_null($route->getName()))
            return null;

        return $this->translateRoute($route->getName(), $route->parameters());
    }
10338
protected function setRouteInfo($request)
    {
        $this->route_info = Route::getWebInfo($request);
        if (!$this->route_info['controller'] || !$this->route_info['action']) {
            $this->route_info['controller'] = 'index';
            $this->route_info['action'] = 'index';
            $home = Lb::app()->getHome();
            if (isset($home['controller']) && isset($home['action']) && $home['controller'] && $home['action']) {
                $this->route_info['controller'] = $home['controller'];
                $this->route_info['action'] = $home['action'];
            }
        }
    }
1243713
public function determineLocale(Request $request)
    {
        $locale = $this->determiners
            ->map(function ($determiner) use ($request) {
                return $determiner->determineLocale($request);
            })
            ->filter()
            ->first();

        return $locale ?: $this->fallback;
    }
414485
public static function route(Http\Request $request)
    {
        $path = $request->REQUEST_URI;
        $key = $request->getMethod().'@'.$path;
        $keyAny = 'ANY@'.$path;

        $matchedRoute = null;
        $matchedScore = 0;

        if (isset(self::$routes[$key])) {
            $matchedRoute = self::$routes[$key];
        } elseif (isset(self::$routes[$keyAny])) {
            $matchedRoute = self::$routes[$keyAny];
        } else {
            foreach (self::$routes as $key2 => $route) {
                if ($route->getMethod() != 'ANY' && $route->getMethod() != $request->getMethod()) {
                    continue;
                }

                $score = $route->getScore($path, $request->getMethod());
                if ($score > $matchedScore) {
                    $matchedRoute = $route;
                    $matchedScore = $score;
                }
            }
        }

        if ($matchedRoute) {
            $matchedRoute->setUrl($path);
        } elseif (self::$_404route) {
            $matchedRoute = self::$_404route;
        } else {
            throw new Exceptions\RouteException('Route not found');
        }
        return $matchedRoute;
    }
339796
public function setRequest(Request $request)
    {
        $this->request = $request;

        $this->input = $request->request->all() + $request->query->all();
    }