Gather the middleware for the given route.

@param  Route $route
@return array
979626
public function gatherRouteMiddlewares( Route $route )
	{
		return Collection::make( $route->middleware() )->map( function ( $name )
		{
			return Collection::make( $this->resolveMiddlewareClassName( $name ) );
		} )->flatten()->all();
	}
203367
static public function getRoutePatternParts( Route $route ){
		$parts	= array();
		foreach( explode( "/", $route->getPattern() ) as $part ){
			$optional	= FALSE;
			$argument	= FALSE;
			if( preg_match( "@\(:.+\)@", $part ) ){													//  optional argument found
				$part		= substr( $part, 1, -1 );												//  cut argument key
				$optional	= TRUE;																	//  note that is optional
			}
			if( substr( $part, 0, 1 ) === ":" ){													//  argument found
				$part		= substr( $part, 1 );													//  cut argument key
				$argument	= TRUE;																	//  note that is argument
			}
			$parts[]	= (object) array(															//  prepare route pattern part object
				'key'		=> $part,
				'optional'	=> $optional,
				'argument'	=> $argument,
			);
		}
		return $parts;
	}
842230
public function gatherRouteMiddlewares($route)
    {
        if (method_exists($this->router, 'gatherRouteMiddleware')) {
            return $this->router->gatherRouteMiddleware($route);
        }

        return $this->router->gatherRouteMiddlewares($route);
    }
400428
private static function parseHostVars(RouteInterface $route)
    {
        if (null === $host = $route->getHost()) {
            return ['expression' => null, 'tokens' => []];
        }

        return self::transpilePattern($host, true, $route->getConstraints(), $route->getDefaults());
    }
216583
private function getUriParams($route)
    {
        preg_match_all('~{(\w+)}~', $this->getRouteParam($route, 'uri'), $matches);
        
        return isset($matches[1]) ? $matches[1] : [];
    }
606735
protected function runRouteWithinStack(Route $route, Request $request)
    {
        $middleware = $this->gatherRouteMiddlewares($route);
        
        return (new Pipeline($this->container))
                        ->send($request)
                        ->through($middleware)
                        ->then(function ($request) use ($route) {
                            return $this->prepareResponse(
                                $request,
                                $route->run($request)
                            );
                        });
    }
1148296
public function parseRoute (Route $route) {

		if (preg_match_all('#^' . $route->getRoute () . '$#', $this->getUrl (), $matches, PREG_OFFSET_CAPTURE)) {

			// Rework matches to only contain the matches, not the orig string
			$matches = array_slice($matches, 1);

			// Extract the matched URL parameters (and only the parameters)
			$params = array_map(function($match, $index) use ($matches) {

				// We have a following parameter: take the substring from the current param position until the next one's position (thank you PREG_OFFSET_CAPTURE)
				if (isset($matches[$index+1]) && isset($matches[$index+1][0]) && is_array($matches[$index+1][0])) {
					return trim(substr($match[0][0], 0, $matches[$index+1][0][1] - $match[0][1]), '/');
				}

				// We have no following paramete: return the whole lot
				else {
					return (isset($match[0][0]) ? trim($match[0][0], '/') : null);
				}

			}, $matches, array_keys($matches));

			if (empty ($params)) {
				return true;
			}
			else {
				return $params;
			}
		}

		return false;
	}
169868
public function getRouteProperties($route, Request $request)
    {
        if (method_exists($route, 'uri') && method_exists($route, 'methods')) {
            return [$route->uri(), $route->methods(), $route->getAction()];
        }

        return [$route->getUri(), $route->getMethods(), $route->getAction()];
    }
1240697
private function getParameters(Contracts\Request $request, $route)
    {
        $path    = $request->path();
        $pattern = $this->pattern($route);
        if (preg_match_all($pattern, $path, $matches, PREG_SET_ORDER) === false) {
            return []; // @codeCoverageIgnore
        }

        unset($matches[0][0]);
        $matches = array_values($matches[0]);

        return $matches;
    }
1209587
protected function routerMatchedHandler(Route $route)
    {
        if ($route->getName()) {
            // someaction (route name/alias)
            $routeName = $route->getName();
        } elseif ($route->getActionName()) {
            // SomeController@someAction (controller action)
            $routeName = $route->getActionName();
        }
        if (empty($routeName) || $routeName === 'Closure') {
            // /someaction // Fallback to the url
            $routeName = $route->uri();
        }

        Integration::addBreadcrumb(new Breadcrumb(
            Breadcrumb::LEVEL_INFO,
            Breadcrumb::TYPE_NAVIGATION,
            'route',
            $routeName
        ));
        Integration::setTransaction($routeName);
    }
1042008
protected function  handleFoundRoute($route, Request $request)
    {
        $this->currentRoute = $route;
        $request->attributes->add($route[2]);

        if (isset($route[1]['middleware']) && !empty($route[1]['middleware'])) {
            $middleware = $route[1]['middleware'];
            $middleware = is_string($middleware) ? explode('|', $middleware) : (array) $middleware;
            $middleware = array_map(function ($m) { return $this->middlewareNamespace .'\\'. $m; }, $middleware);

            $response = (new Pipeline())->send($request)->through($middleware)
                ->then(function () use ($route, $request) {
                    return $this->callAction($route, $request);
                });
        }
        else {
            $response = $this->callAction($route, $request);
        }

        if (!$response instanceof Response) {
            $response = new Response($response);
        }

        return $response;
    }
823978
protected function buildRoute(Route $route)
    {
        if ($route->getBlock()) {
            return $route;
        }

        list($pattern, $params) = $this->parsePlaceholders($route->getPattern());
        return $route->setPatternWithoutReset($pattern)->setParams($params)->setBlock(true);
    }
291414
public static function getMiddleware($controller, $method)
    {
        if (! method_exists($controller, 'getMiddleware')) {
            return array();
        }

        $results = array();

        foreach ($controller->getMiddleware() as $middleware => $options) {
            if (static::methodExcludedByOptions($method, $options)) {
                continue;
            }

            $results[] = $middleware;
        }

        return $results;
    }
709352
protected function gatherInvokerMiddleware($middleware)
    {
        $nameMiddleware = $this->config['name_middleware'] ?? [];
        $middlewareGroups = $this->config['middleware_groups'] ?? [];

        return Collection::make($middleware)->map(function ($middleware) use ($nameMiddleware, $middlewareGroups) {
            return (array) MiddlewareNameResolver::resolve($middleware, $nameMiddleware, $middlewareGroups);
        })->flatten()->all();
    }
813167
public function getFromRequest($route = null) {
        $resolvers = [];
        foreach ($this->segmentsResolvers as $key => $resolverClass) {
            if( $bindedClass = request()->route($key) ) {
                $resolvers[$key] = new $resolverClass($bindedClass);
            }
        }
        // sort resolvers in same order they are in request
        if (!empty($resolvers)) {
            if (empty($route)) {
                $route = \Route::getCurrentRoute()->uri();
            }       
            $segments = explode('/', $route);
            $sortedResolvers = [];
            foreach($segments as $segment) {
                $segment = trim($segment, "{}");
                if (isset($resolvers [$segment])) {
                    $sortedResolvers[$segment] = $resolvers[$segment];
                }
            }
            $resolvers = $sortedResolvers;
        }
        return empty($resolvers) ? false  : $resolvers;
    }
139867
protected function gatherRoutes()
    {
        // Get the base route path
        $basePath = $this->container->get('app.base_path');
        $routesPath = $this->container->get('app.routes_path');

        // Include the route file
        include $basePath . DIRECTORY_SEPARATOR . $routesPath;
    }
1023261
private static function gatherMiddleware(IlluminateRoute $route)
    {
        /** @var  array  $middleware */
        $middleware = $route->middleware();

        return is_callable([$route, 'controllerMiddleware'])
            ? array_unique(array_merge($middleware, $route->controllerMiddleware()), SORT_REGULAR)
            : $middleware;
    }