获取一个Controller
@param $controller string
@return Controller
164786
public function getController($controller)
    {
        if ($controller == null) return null;
        $controllers = $this->pool[$controller] ?? null;
        if ($controllers == null) {
            $controllers = $this->pool[$controller] = new \SplQueue();
        }
        if (!$controllers->isEmpty()) {
            $controller_instance = $controllers->shift();
            $controller_instance->reUse();
            return $controller_instance;
        }
        if (class_exists($controller)) {
            $controller_instance = new $controller;
            if ($controller_instance instanceof Controller) {
                $controller_instance->core_name = $controller;
                $this->addNewCount($controller);
                return $controller_instance;
            }
        }
        $controller_new = str_replace('/', '\\', $controller);
        $class_name = "app\\Controllers\\$controller_new";
        if (class_exists($class_name)) {
            $controller_instance = new $class_name;
            $controller_instance->core_name = $controller;
            $this->addNewCount($controller);
            return $controller_instance;
        } else {
            if (!$this->allow_ServerController) {
                return null;
            }
            $class_name = "Server\\Controllers\\$controller_new";
            if (class_exists($class_name)) {
                $controller_instance = new $class_name;
                $controller_instance->core_name = $controller;
                $this->addNewCount($controller);
                return $controller_instance;
            } else {
                return null;
            }
        }
    }
1371188
public function findController($controller)
    {
        $file = $this->basePath("app/Controller/$controller.php");
        if($this->findFile($file)) {
            return true;
        }
        else {
            throw new Exception($file." Controller file is missing.");
            exit;
        }
    }
126933
protected function callController($controller)
    {
        if (is_string($controller) && strpos($controller, self::SEPARATOR) !== false) {
            list($controller, $action) = explode(self::SEPARATOR, $controller);
            $response = $this->callClassController($controller, $action);
        } elseif (is_callable($controller)) {
            $response = $this->callCallableController($controller);
        } else {
            throw new AppException(sprintf('Invalid controller type, got "%s"', $this->getType($controller)));
        }

        if (!$response) {
            throw new AppException(sprintf('There was no response returned from the controller handling "%s"', $this->request()->uri(true)));
        }

        if (!$response instanceof ResponseInterface) {
            throw new AppException(sprintf('Invalid response returned from handling "%s", expected ResponseInterface, got "%s"', $this->request()->uri(true), $this->getType($response)));
        }

        return $response;
    }
284278
public function indexByController( $controller ){
		$routes		= array();
		foreach( $this->routes as $route ){
			if( $route->getController() === $controller ){
				$routes[]	= $route;
			}
		}
		return $routes;
	}
4118
public function getActions($controller)
    {
        $actions = [];
        foreach (get_class_methods($controller) as $method) {
            if (preg_match('#^(.*)Action$#', $method, $match)) {
                $actions[] = $match[1];
            }
        }

        return $actions;
    }
856137
protected function makeController($controller)
	{
		Controller::setRouter($this->router);

		return $this->container->make($controller);
	}
1162837
public function loadController($controller)
    {
        if (!isset($this->_loadedControllers[$controller])) {
            $controllers = static::controllers();
            if (isset($controllers[$controller])) {
                $className = $controllers[$controller];
                $tagName = $controller;
            } else {
                $className = $this->getNamespace() . '\\controllers\\' . NamesHelper::urlToClass($controller) . 'Controller';
            }
            if (class_exists($className)) {
                $instance = new $className([], $this);
                $instance->setTagName($controller);
                $this->_loadedControllers[$controller] = $instance;
            }
        }
        return $this->_loadedControllers[$controller];
    }
1267831
public function build($controller, array $vars = array())
    {
        $template = $this->mapManager->getUrlTemplateByController($controller);

        if ($template !== false) {
            if ($this->hasVar($template)) {
                return $this->prepare($controller, $template, $vars);
            } else {
                return $template;
            }

        } else {
            // Wrong controller, so nothing to return there
            return null;
        }
    }
1204205
public function setViewController($controller)
    {
        if (is_scalar($controller) || is_resource($controller)) {
            throw new InvalidArgumentException(
                'View controller must be an object, null or an array'
            );
        }

        $this->viewController = $controller;

        return $this;
    }
1316463
public function hasController(string $controller): bool
    {
        foreach ($this->items as $item) {
            if (
                $item->getTarget() == $controller
                || strpos($item->getTarget(), $controller . ':') === 0
            ) {
                return true;
            }
        }

        return false;
    }
1121413
protected function createController($controller)
    {
        if (false === strpos($controller, '::')) {
            throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller));
        }

        list($class, $method) = explode('::', $controller, 2);

        if ($this->container->has($class)) {
            $controller = $this->container->get($class);
        } else {
            if ( ! class_exists($class)) {
                throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
            }

            $controller = new $class();
        }

        if ($controller instanceof ContainerAwareInterface) {
            $controller->setContainer($this->container);
        }

        return array($controller, $method);
    }
414275
public function changeController( Controller $controller )
	{
		if( isset($this->ci["Controller"]) && method_exists( $this->ci["Controller"], "change" ) && ! $this->ci["Controller"]->change() )
		{
			throw new \Exception("Current controller '" . get_class( $this->ci["Controller"] ) . "' does not allow change");
		}

		$this->ci["Controller"] = $controller;
		$this->Controller = $controller;

		return $this->Controller;
	}
68589
public function onControllerInit(BaseController $controller)
    {
        // 除去 admin/login 页面
        if (substr($this->app->getController(), 0, 6) === 'admin/') {
            $controller->middleware(CheckAppStatus::class);
        }

        $this->checkCli();
    }
1369435
protected function createController($controller)
    {
        if (false === strpos($controller, '::')) {
            throw new \InvalidArgumentException(sprintf('Unable to find controller "%s".', $controller));
        }

        list($class, $method) = explode('::', $controller, 2);

        if (!class_exists($class)) {
            throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
        }

        return array(new $class(), $method);
    }
569770
public function setController($controller)
        {
            if (null !== $controller && !is_string($controller)) {
                throw new Exception(
                    'Invalid argument: $controller must be a string or null'
                );
            }

            $this->_controller = $controller;
            $this->_hrefCache  = null;

            return $this;
        }
826801
public function initController($controller, $path)
    {
        if($path)
        {
            $controller = $this->name . '\\Controller\\' . $path . '\\' . $controller;
        }
        else
        {
            $controller = $this->name . '\\Controller\\' . $controller;
        }

        return new $controller();
    }
1261595
public function routeController($controller): Controller
    {
        $actions = $this->getActions();

        foreach ($actions as $key => $action) {
            $method = ucfirst(Inflector::pathAction($action));

            if (method_exists($this, 'set' . $method . 'Route')) {
                $this->{'set' . $method . 'Route'}(Inflector::deCamelize($controller), $action);
            }
        }

        $this->mapRoute();

        return $this;
    }