@param Request $request
@param Route $route
@param array $parameters

@return Response
559258
public function execute(Request $request, Route $route, $parameters)
    {
        $request->attributes->set('_controller', $this->getControllerCallback());
        $app = Facade::getFacadeApplication();
        $controllerResolver = $app->make(ApplicationAwareControllerResolver::class);
        $callback = $controllerResolver->getController($request);
        $argumentsResolver = $app->make(ArgumentResolver::class);

        $arguments = $argumentsResolver->getArguments($request, $callback);
        $controller = $callback[0];
        $method = $callback[1];

        if (method_exists($controller, 'on_start')) {
            $controller->on_start();
        }

        if (method_exists($controller, 'runAction')) {
            $response = $controller->runAction($method, $arguments);
        } else {
            $response = call_user_func_array([$controller, $method], $arguments);
        }

        if ($response instanceof Response) {
            // note, our RedirectResponse doesn't extend Response, it extends symfony2 response
            return $response;
        }

        if ($response instanceof AbstractView) {
            $content = $response->render();
        } else if (method_exists($controller, 'getViewObject')) {
            $content = null;
            $view = $controller->getViewObject();
            if (is_object($view)) {
                $view->setController($controller);
                if (isset($view) && $view instanceof AbstractView) {
                    $content = $view->render();
                }
            }
        } else {
            $content = $response;
        }

        if (is_object($content)) {
            return $content;
        }

        $response = new Response();
        $response->setContent($content);
        return $response;
    }
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;
		}
	}
35887
protected function callFilter($filter, $route, $request)
	{
		extract($filter);

		return $this->filterer->callRouteFilter($filter, $parameters, $route, $request);
	}
408652
protected function  generateUrl($route,array $parameters){
        return $this->container->get('router')->generate($route, $parameters, Router::ABSOLUTE_URL);
    }
925009
protected function getUrl($route, array $parameters = [], $useRequest = false)
    {
        $router = $this->getContext()->getComponent()->getRouter();

        if ($useRequest) {
            $request = $this->getContext()->getRequest();

            $parameters += $request->getParams(IComponentRequest::ROUTE)->toArray();
        }

        return $router->assemble($route, $parameters) ?: '/';
    }
497816
public function redirect($route, $parameters = array(), $status = 302, $headers = array())
    {
        return Redirect::route('admin.'.$route, $parameters, $status, $headers);
    }
1156465
public function matches(Route $route, Request $request)
    {
        if (call_user_func_array($route->getCondition(), $route->getConditionParameters())) {
            return true;
        }

        return false;
    }
1339738
protected function handleMatched(Route $route, Request $request)
    {
        $name = $route->getName();

        list($packageName, $routeName) = StringHelper::explode('@', $name, 2, 'array_unshift');

        $variables = $route->getVariables();
        $extra     = $route->getExtraValues();
        $input     = $this->app->input;

        // Save to input & ServerRequest
        $input->merge($variables, true);
        // Don't forget to do an explicit set on the GET superglobal.
        $input->get->merge($variables, true);
        $request = $request->withQueryParams($input->get->getRawData());

        $this->app->server->setRequest($request);

        // Store to config
        $this->app->set('route', [
            'matched' => $route->getName(),
            'package' => $packageName,
            'short_name' => $routeName,
            'extra' => $extra,
        ]);

        // Package
        $package = $this->getPackageResolver()->resolvePackage($packageName);

        $this->app->container->share('current.package', $package);
        $this->app->container->share('current.route', $route);

        // Set middlewares
        $middlewares = $route->getExtra('middlewares') ?: [];

        foreach ($middlewares as $middleware) {
            $package->addMiddleware($middleware);
        }

        return $request->withAttribute('_controller', Arr::get($extra, 'controller'));
    }
94999
protected function populateContent(Route $route, Request $request)
    {
        $content = $route->getContent();
        $name    = $content;

        if ($route->isList()) {
            $name .= 's';
            $value = $this->repository->getContents($content, $route->getIndexBy(), $route->getOrder());

            if ($route->isPaginated()) {
                $paginator = new Paginator($value, $route->getPerPage());
                $value     = $paginator->get($request->attributes->get('page'));
                $request->attributes->set('paginator', $paginator);
            }
        } else {
            $value = $this->repository->getContent($content, $request->attributes->get($content));
        }

        $request->attributes->set($name, $value);
    }
684355
public function callAction($route, Request $request)
    {
        if ($request->isMethod('OPTIONS')) {
            return new Response(null, 200);
        }

        // 闭包
        foreach ($route[1] as $value) {
            if ($value instanceof Closure) {
                return call_user_func_array($value, $route[2]);
                break;
            }
        }

        list($class, $method) = explode('@', $route[1]['uses']);
        $controller = $this->namespace.'\\'.$class;
        $instance =  new $controller();

        if (!method_exists($instance, $method)) {
            return call_user_func_array([$instance, "missingMethod"], [$method, $route[2]]);
        }

        return call_user_func_array([$instance, $method], $route[2]);
    }
673399
protected function render_route($route, $params = []) {

        $output = false;

        if (isset($this->routes[$route])) {

            $ret = null;

            if (\is_callable($this->routes[$route])){
                $ret = \call_user_func($this->routes[$route], $params);
            }

            if (!is_null($ret)){
                return $ret;
            }
        }

        return $output;
    }
806462
protected function runRouteWithinStack( Route $route, Request $request )
	{
		$middleware = HttpFactory::i()->isMiddlewareDisabled() ? [] : $this->gatherRouteMiddlewares( $route );

		return ( new Pipeline() )->send( $request )->through( $middleware )->then( function ( $request ) use ( $route )
		{
			return $this->prepareResponse( $request, $route->run( $request ) );
		} );
	}
1075678
public static function registerRoute($controller, $parameters = [])
    {
        \Route::group($parameters, function ($controller) {
            \Route::registerController($controller);
        });
    }
638147
public static function route($route, array $params = array())
    {
        list($controller, $action) = Route::routeToAction($route);
        $controller = substr($controller, 0, strlen($controller) - strlen('Controller'));
        $action = substr($action, 0, strlen($action) - strlen('Action'));

        $path = "/" . str_ireplace('\\', '/', $controller) . '/' . $action;
        $query = http_build_query($params);

        $url = $path . (empty($query) ? '' : ('?' . $query));

        return $url;
    }
857909
protected function other(Request $request, Response $response, Route $route)
    {
        $request;
        $response = $response->withStatus(500)
            ->withHeader('Content-Type', 'text/plain');
        $message = sprintf(
            'Route "%s" failed for rule "%s"',
            $route->name,
            $route->failedRule
        );
        $response->getBody()->write($message);
        return $response;
    }
7705
protected function callAttachedBefores($route, $request)
	{
		foreach ($route->beforeFilters() as $filter => $parameters)
		{
			$response = $this->callRouteFilter($filter, $parameters, $route, $request);

			if ( ! is_null($response)) return $response;
		}
	}
1300368
protected function computeMissingRouteParameters(Route $route, array $parameters): array
    {
        $compiledRoute = $route->compile();
        $variables = array_flip($compiledRoute->getVariables());
        $mergedParams = array_replace($route->getDefaults(), $this->router->getContext()->getParameters(), $parameters);

        return array_flip(array_diff_key($variables, $mergedParams));
    }