Set up middleware for a found route

@param \League\Route\Route $route

@return void
481518
protected function setFoundMiddleware(Route $route) : void
    {
        if (is_null($route->getStrategy())) {
            $route->setStrategy($this->getStrategy());
        }

        // wrap entire dispatch process in exception handler
        $this->prependMiddleware($route->getStrategy()->getExceptionHandler());

        // add group and route specific middleware
        if ($group = $route->getParentGroup()) {
            $this->middlewares($group->getMiddlewareStack());
        }

        $this->middlewares($route->getMiddlewareStack());

        // add actual route to end of stack
        $this->middleware($route);
    }
1275482
public function registerRoute (Route $route, $routeIdentifier = null)
		{
			if (! $routeIdentifier) {
				$routeIdentifier = uniqid();
			}

			$this->routes[$routeIdentifier] = $route;
		}
956293
public function runRouteMiddleware($middleware, $type)
    {
        $middlewarePath = $this->baseFolder . '/' . $this->paths['middlewares'];
        $middlewareNs = $this->namespaces['middlewares'];
        if ($type == 'before') {
            if (! is_null($middleware['group'])) {
                $this->routerCommand()->beforeAfter(
                    $middleware['group'][$type], $middlewarePath, $middlewareNs
                );
            }
            $this->routerCommand()->beforeAfter(
                $middleware[$type], $middlewarePath, $middlewareNs
            );
        } else {
            $this->routerCommand()->beforeAfter(
                $middleware[$type], $middlewarePath, $middlewareNs
            );
            if (! is_null($middleware['group'])) {
                $this->routerCommand()->beforeAfter(
                    $middleware['group'][$type], $middlewarePath, $middlewareNs
                );
            }
        }
    }
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;
    }
229947
public function add(Route $route)
    {
        // $this->routes[$route->method()][$route->uri()] = $route;
        $this->routes[$route->method().$route->route()] = $route;
        return $route;
    }
396918
public function processRoute($route) {
		if( !$route ) {
			throw new NotFoundException('No route matches the current request '.$this);
		}
		$this->setRoute($route);
		return $this->route->run($this);
	}
1317389
public static function add(Route $route)
    {
        exception_if(self::checkDuplicated($route), RouteDuplicatedException::class, $route);

        // Create new route for url ended with '/'
        $routeWithoutSlash = $route;
        $routeWithSlash = $route->getWithSlash();

        self::$register[$routeWithoutSlash->getName()] = $routeWithoutSlash;
        self::$register[$routeWithSlash->getName()] = $routeWithSlash;
    }
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;
			}
		}
	}
575721
public function dispatch(Route $route)
    {
        $this->beforeStart();

        return $this->router->dispatch($route, $this->request);
    }
830586
public function registerMiddleware(Router $router)
    {
        foreach ($this->middleware as $module => $middlewares) {
            foreach ($middlewares as $name => $middleware) {
                $class = "Modules\\{$module}\\Http\\Middleware\\{$middleware}";

                $router->middleware($name, $class);
            }
        }
    }
1204131
public function dispatch(Route $route)
    {
        do {
            $this->getEventManager()->publish("pre.dispatch", array($route, $this));

            $protoView = $this->_view->cloneThis();
            $controllerClassName = $route->getControllerName() . "Controller";
            $action = $route->getActionName() . "Action";
            $classPath = $this->getControllerPath() . DIRECTORY_SEPARATOR . $controllerClassName . ".php";
            $viewPath = $route->getControllerPath()
                . DIRECTORY_SEPARATOR
                . $route->getActionPath()
                . $protoView->getViewExt();

            if (!file_exists($classPath)) {
                // Use base controller
                $controllerClassName = 'Controller';
            } else {
                require_once $classPath;
            }

            $controller = new $controllerClassName($this);
            $controller->setRouter($this->getRouter());
            $controller->setRequest($this->getRequest());
            $controller->setParams(
                array_merge(
                    array(
                        "dispatcher" => $this,
                        "bootstrap" => $this->getBootstrap()
                    ),
                    $route->getParams()));
            $controller->setRawBody(@file_get_contents('php://input'));

            $controller->setView($protoView->cloneThis());
            $controller->view->controllerPath = $this->getControllerPath();

            if (method_exists($controller, $action)) {
                ob_start();
                $controller->init();
                $controller->$action();
                array_push($this->_viewsQueue, ob_get_contents());
                ob_end_clean();
            } else {
                if (!file_exists($controller->view->getViewPath() . DIRECTORY_SEPARATOR . $viewPath)) {
                    throw new RuntimeException("Page not found {$route->getControllerName()} -> {$route->getActionName()}", 404);
                }
            }

            if ($controller->view->getViewPath()) {
                array_push(
                    $this->_viewsQueue,
                    $controller->getView()->render(
                        (($controller->getViewPath() !== false) ? $controller->getViewPath() : $viewPath))
                );
            }

            $this->getEventManager()->publish("post.dispatch", array($this));
        } while(($route = array_shift($this->_actions)));

        return implode("", $this->_viewsQueue);
    }
1127051
protected function addToCollections($route)
	{
		$domainAndUri = $route->domain() . $route->getUri();

		foreach ($route->methods() as $method)
		{
			$this->routes[$method][$domainAndUri] = $route;
		}

		$this->allRoutes[$method . $domainAndUri] = $route;
	}
709553
protected function callPatternFilters($route, $request)
	{
		foreach ($this->findPatternFilters($request) as $filter => $parameters)
		{
			$response = $this->callRouteFilter($filter, $parameters, $route, $request);

			if ( ! is_null($response)) return $response;
		}
	}
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');
    }
902811
public function addRoute(Route $route) : ParsedRoute
    {
        $route = $this->applyGroupSettings($route);
        $parsedRoute = $this->parser->parse($route);
        $this->routeCollection->add($parsedRoute);

        return $parsedRoute;
    }
902724
public function redirectTo($route = null)
    {
        if (is_null($route)) {
            $url = $this->di->request->getCurrentUrl();
        } else {
            $url = $this->di->url->create($route);
        }
        $this->di->response->redirect($url);
    }
140508
public function addMiddleware(Middleware $middleware)
    {
        $group = $middleware->getGroup();
        if (! isset($this->middleware[$group])) {
            $this->middleware[$group] = array(
                'before' => array(),
                'after' => array()
            );
        }

        $this->middleware[$group][$middleware->getPosition()][] = &$middleware;
    }