Validate and return a cleansed version from a given route
@param array $route
@return array|boolean false
359798
private function isValidRoute(array $route)
    {
        if (!array_key_exists('path', $route)) {
            return false;
        }

        if (!array_key_exists('view.directRender', $route)) {
            $route['view.directRender'] = false;
        } else {
            if (!is_bool($route['view.directRender'])) {
                return false;
            }
        }

        if (!array_key_exists('view.layout', $route)) {
            $route['view.layout'] = false;
        } else {
            if (!is_string($route['view.layout'])) {
                return false;
            }
        }

        if (!array_key_exists('method', $route)) {
            $route['method'] = 'GET';
        }

        if (!array_key_exists('allow', $route)) {
            $route['allow'] = array();
        }

        if (!array_key_exists('from', $route['allow'])) {
            $route['allow']['from'] = '';
        }

        if (!array_key_exists('roles', $route['allow'])) {
            $route['allow']['roles'] = '';
        }

        $route['method'] = strtoupper($route['method']);

        if (!array_key_exists('params', $route)) {
            $route['params'] = array();
        }

        return $route;
    }
99888
public function inflect(Route $route)
    {
        $file  = $route->attributes['controller'].'/';
        $file .= $route->attributes['action'];
        $filtered = self::camelCaseToSeparator($file, '_');
        $filtered = str_replace('_', '-', strtolower($filtered));
        return "{$filtered}.{$this->extension}";
    }
165833
private function getMiddleWareFromRoute(Route $route)
    {
        if (!$route->group) {
            return $route->middleWare;
        }
        $groupMiddleWare = $this->getMiddleWareFromGroup($route->group);
        return \array_merge($groupMiddleWare, $route->middleWare);
    }
1157475
protected function filterByScopes(array $route)
    {
        foreach ($this->option('scopes') as $scope) {
            if (Str::contains($route['scopes'], $scope)) {
                return true;
            }
        }

        return false;
    }
1268472
public function remove(array $routes): bool
    {
        foreach ($routes as $route) {
            $item = $this->manager->createPermission('/' . trim($route, '/'));
            $this->manager->remove($item);
        }
        $this->invalidate();

        return true;
    }
1187823
protected function verifyRequired($route)
    {
        $request = Yii::$app->getRequest();
        Yii::$app->session->set($this->buildKey('_url'), [$route, $request->getUrl()]);
        $id = $this->owner->uniqueId . '/' . $this->verificationRoute;
        return Yii::$app->getResponse()->redirect([$id]);
    }
433932
private static function runRouteMiddleware($route)
    {
        $routeMiddleware = Filter::$routeMiddleware;

        if (!is_null($route->getMiddleware())) {
            // if ($route->getMiddleware()['type'] == 'route' && ! is_null($route->getMiddleware()['middlewares'])) {
            foreach ($route->getMiddleware() as $middleware) {
                //Check if the routes middlewares are in filter class
                exception_if(!array_has($routeMiddleware, $middleware), RouteMiddlewareNotFoundException::class, $middleware);

                $middleware = instance($routeMiddleware[$middleware]);

                $middleware->handle(new Request());
            }
        }

        return true;
    }
662790
private function isRequestAcceptedForRoute($route)
    {
        $acceptedFormats = $route['acceptedRequestFormats'];
        if (is_null($acceptedFormats)) {
            return true;
        }
        if (is_array($acceptedFormats)) {
            foreach ($acceptedFormats as $format) {
                if (strpos($this->requestedRepresentation, $format) !== false) {
                    return true;
                }
            }
            return false;
        }
        return strpos($this->requestedRepresentation, $acceptedFormats) !== false;
    }
990194
public function normalize($route)
	{
		//make sure that all urls have the same structure
		/* Fix trailling shash */
		if (mb_substr($route, -1, 1) == "/") {
			$route = substr($route, 0, -1);
		}

		$result    = explode("/", $route);
		$result[0] = $this->baseUri;
		$ret       = [];

		//check for dynamic and optional parameters
		foreach ($result as $v) {

			if (!$v) {
				continue;
			}
			if (($v[0]) === "?{") {
				$ret[] = [
					"name" => explode("?}", mb_substr($v, 1))[0],
					"use"  => "?"
				];
			} else if (($v[0]) === "{") {
				$ret[] = [
					"name" => explode("}", mb_substr($v, 1))[0],
					"use"  => "*"
				];
			} else {
				$ret[] = [
					"name" => $v,
					"use"  => $v
				];
			}
		}

		return $ret;
	}
483824
public function gatherRouteMiddleware(Route $route)
    {
        $middleware = collect($route->gatherMiddleware())->map(function ($name) {
            return (array) MiddlewareNameResolver::resolve($name, $this->middleware, $this->middlewareGroups);
        })->flatten();

        return $this->sortMiddleware($middleware);
    }
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;
    }
1364623
public static function transRouteExternal($route) {
        $app = app();
        $locale = \Sirgrimorum\CrudGenerator\CrudGenerator::setLocale();
        //$locale = $app->getLocale();
        $transroute = $app->translator->trans($route, [], $locale);
        return $transroute;
    }
61288
public function matches(Route $route, Request $request)
    {
        $regex = $route->getCompiled()->getRegex();

        if (str_contains($request->getRequestUri(), '/wp-admin')) {
            return preg_match(str_replace('$#s', '(?:&.+)?$#s', $regex), rawurldecode($request->getRequestUri()));
        }

        $path = $request->path() == '/' ? '/' : '/' . $request->path();

        return preg_match($regex, rawurldecode($path));
    }
287408
private function overlay(array $route): array
    {
        $target = $this->defaults;

        foreach ($route['route']['target'] as $key => $value) {
            $target[$key] = $value;
        }

        return $target;
    }
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;
			}
		}
	}
632663
public function getModelFromRoute(Route $route)
    {
        $ret = false;
        $controller = $this->getControllerFromRoute($route);

        if ($controller instanceof RestController) {
            $ret = $controller->getModel();
        }

        return $ret;
    }
590417
private function methodMatches(array $route)
    {
        $methods = explode('|', $route['method']);
        if (in_array($this->method, $methods)) {
            return true;
        }

        return false;
    }