Check and complete a route

@param CCRoute 			$route
@param mixed				$raw_route
@return false|CCRoute
424061
protected static function configure( $route, $raw_route ) 
	{	
		// deal with emptiness
		if ( is_null( $raw_route ) )
		{
			return false;	
		}
		// this might be a controller
		if ( is_string( $raw_route ) ) 
		{	
			// are there overwrite parameters?
			if ( strpos( $raw_route, '?' ) !== false ) 
			{
				$route->params = explode( ',', CCStr::suffix( $raw_route, '?' ) );
				$raw_route = CCStr::cut( $raw_route, '?' );
			}
			
			// is there a overwrite action?
			if ( strpos( $raw_route, '@' ) !== false ) 
			{
				$route->action = CCStr::suffix( $raw_route, '@' );
				$raw_route = CCStr::cut( $raw_route, '@' );
			}
			
			// try creating an controller instance
			$controller = CCController::create( $raw_route );
			
			// set the callback on controller execute
			$route->callback = array( $controller, 'execute' );
		}
		// is the route callable set it up
		elseif ( is_callable( $raw_route ) ) 
		{
			$route->callback = $raw_route;
		}
		
		return $route;
	}
1196865
public function checkRouteAccess($route)
    {
        UserOnline::refreshUser($this->userAuthClass()->identity, $route);
        
        if (!Yii::$app->auth->matchRoute($this->userAuthClass()->identity->id, $route)) {
            throw new ForbiddenHttpException('Unable to access this action due to insufficient permissions.');
        }
    }
1341635
private function cacheGet(Route $route, string $cacheKey)
    {
        if ($route->getOption(AbstractRoute::OPTIONS_CACHE)) {
            if ($data = self::cache(self::class)->get($cacheKey)) {
                foreach ($data['headers'] as $name => $header) {
                    self::response()->addHeader($name, $header);
                }

                return $data['output'];
            } else {
                return false;
            }
        }

        return false;
    }
1336278
private function matchesRequest($route)
    {
        $requestURL = $this->requestURL;
        if (isset($route['fullDomainMatch']) && $route['fullDomainMatch'] == true) {
            $requestURL = $this->fullRequestURL;
        }
        if (isset($route['method']) && $route['method'] != $this->requestMethod) {
            return false;
        }
        return preg_match($route['match'], $requestURL, $this->matches);
    }
621386
public function processRouteFilters(Route $route)
	{
		foreach ($this->filterByRoute($route) as $filter) {

			$result = call_user_func_array($filter, func_get_args());
			
			if ($result !== null) {

				return $result;
			}
		}
	}
943022
protected function matches(Route $route, string $path): bool
	{
		if(preg_match($route->getRegex(), $path, $parameters) > 0)
		{
			$filtered = [];

			foreach($parameters as $key => $value)
			{
				if(is_string($key))
				{
					$filtered[$key] = $value;
				}
			}

			$route->setParameters($filtered);

			return true;
		}

		return false;
	}
919737
public static function routeExists($route, sfContext $context)
    {
        try {
            if ($route{0} == '@') {
                $context->getRouting()->generate(substr($route, 1));
            }
            return true;
        } catch (Exception $e) {
            return false;
        }
    }
1179199
public function processRequest(Request $request, Route $route)
    {
        $givenToken = $request->headers->get(self::HEADER);

        $session = $request->getSession();
        $expectedToken = $session->get(self::CSRF);
        if ($request->isMethod('GET') && (!$route->hasOption(self::CSRF)) || $route->hasDefault('_guest')) {
            if (empty($expectedToken)) {
                $this->renewCsrfToken();
            }
            return;
        }

        if (empty($givenToken) || $givenToken !== $expectedToken) {
            throw new MethodNotAllowedException(['POST'], 'invalid CSRF token');
        }

        $this->generateNewTokenWhenNeeded($session);
    }
1369769
private static function routeMatch(string $request_url, string $request_method, Route $route) :bool {

		// if the method is set for that route, and it doesn't match
		if(!$route->hasMethod($request_method)) {
			return false;
		}
		// if the url doesn't begin with the static segment or that route
		if(!$route->hasStaticUrlSegment($request_url)) {
			return false;
		}
		// if we've got a redirect, let's go for it
		$route->redirectIfItIsOne();
		// get a list of current request parameters, with numerical indexes
		$indexed_request_parameters = Request::getUrlIndexedParameters($route->staticSegment);
		// if restricttion against url parameters don't match
		if(!$route->validatesTheseParameters($indexed_request_parameters)) {
			return false;
		}
		// send the named parameters to the request class
		$route->sendNamedParametersToRequest($indexed_request_parameters);
		// deduce the dynamic action from the url parameters if necessary
		$route->deduceAction();
		// check if they match defined constraints
		return true;

	}
1322725
public static function isStaticRoute(string $route): bool
    {
        return \strpos($route, '{') === false && \strpos($route, '[') === false;
    }
441433
protected function processRoute(): bool
    {
        $uri = $this->getCleanUri();
        $uri = trim($uri, '/');
        $raw = explode('/', $uri);

        // rewrite module from request
        if (\count($raw)) {
            $this->setParam('_module', array_shift($raw));
        }
        // rewrite module from controller
        if (\count($raw)) {
            $this->setParam('_controller', array_shift($raw));
        }
        if ($size = \count($raw)) {
            // save raw
            $this->rawParams = $raw;

            // save as index params
            foreach ($raw as $i => $value) {
                $this->setParam($i, $value);
            }

            // remove tail
            if ($size % 2 === 1) {
                array_pop($raw);
                $size = \count($raw);
            }
            // or use array_chunk and run another loop?
            for ($i = 0; $i < $size; $i += 2) {
                $this->setParam($raw[$i], $raw[$i + 1]);
            }
        }
        return true;
    }
543277
public function checkRoute($route,$active=null,$inactive=null)
    {
        $this->setReturnValue($active,$inactive);

        if (is_array($route)) {
            $result = call_user_func_array(array($this,'routeIsDeeply'), $route);
        } else {
            $result = $this->routeIsDeeply($route);   
        }

        return $result ? $this->activeValue : $this->inActiveValue;
    }
237085
public function rawRoute($var = null)
    {
        if ($var !== null) {
            $this->raw_route = $var;
        }

        if (empty($this->raw_route)) {
            $parent = $this->parent();
            $baseRoute = $parent ? (string)$parent->rawRoute() : null;

            $slug = $this->adjustRouteCase(preg_replace(PAGE_ORDER_PREFIX_REGEX, '', $this->folder));

            $this->raw_route = isset($baseRoute) ? $baseRoute . '/' . $slug : null;
        }

        return $this->raw_route;
    }
121038
public function HasRoute ($routeOrRouteName) {
		if (is_string($routeOrRouteName)) {
			return isset($this->routes[$routeOrRouteName]);
		} else /*if ($routeOrRouteName instance of \MvcCore\IRoute)*/ {
			return (
				isset($this->routes[$routeOrRouteName->GetName()]) || 
				isset($this->routes[$routeOrRouteName->GetControllerAction()])
			);
		}
		//return FALSE;
	}
478129
public static function verify($route, $path, $method=null)
    {
        /*
         * check method comparison, if method is specified.
         */
        $routeMethod = $method;
        if (strpos($route, ':') !== false && substr($route, 0, 1) !== '/' ) {
            list($routeMethod, $route) = explode( ':', $route, 2 );
            $routeMethod = strtolower($routeMethod);
            if ($method === '*') {
                // no matching against method!
            }
            elseif (strcmp(strtolower($method), $routeMethod)) {
                return [];
            }
        }
        $route = '/'.ltrim($route, '/');
        $path  = '/'.ltrim($path, '/');
        /*
         * now verify route against the path.
         */
        // replace {name} => (?P<name>[-_0-9a-zA-Z]+)
        $route = preg_replace_callback(
            '/{([_:*0-9a-zA-Z]+)}/',
            [self::class,'identifier'],
            $route
        );
        if(substr($route, -1) === '*') {
            $route  = substr($route, 0, -1 ) . '(.*)';
        }
        // now match the route against the path.
        if (preg_match('#^'.$route.'$#', $path, $matches)) {
            if(isset($matches['trailing'])) { // with *
                if(!$matches['trailing']) {
                    $matches['matched'] = $matches[0];
                } else {
                    $matches['matched'] = substr($path, 0, -strlen($matches['trailing']));
                }
            }
            $matches['method'] = $routeMethod;
            return $matches;
        }
        return [];
    }
301846
private static function getParents($rawRoutes)
    {
        $grav = Grav::instance();

        /** @var Pages $pages */
        $pages = $grav['pages'];

        $parents = $pages->getList(null, 0, $rawRoutes);

        if (isset($grav['admin'])) {
            // Remove current route from parents

            /** @var Admin $admin */
            $admin = $grav['admin'];

            $page = $admin->getPage($admin->route);
            $page_route = $page->route();
            if (isset($parents[$page_route])) {
                unset($parents[$page_route]);
            }

        }

        return $parents;
    }
323683
private function findModuleInRoute($route)
    {
        $route = parse_url($route, PHP_URL_PATH);
        
        $parts = array_values(array_filter(explode('/', $route)));
        
        if (isset($parts[0]) && array_key_exists($parts[0], Yii::$app->getApplicationModules())) {
            return $parts[0];
        }
    
        return false;
    }