Make a controller instance via the IoC container.

@param  string $controller

@return mixed
504487
protected function makeController($controller)
    {
        Controller::setRouter($this->router);

        $controller = $this->container->make($controller);

        if ( ! $controller instanceof AdminPageController)
        {
            if ($this->container->isShared('post'))
            {
                $controller->setPost($this->container['post']);
            }

            $controller->setQuery($this->container['query']);
        }

        if (method_exists($controller, 'boot'))
        {
            $this->container->call([$controller, 'boot']);
        }

        return $controller;
    }
1084348
private function createController(\ReflectionClass $controllerName)
    {
        $controller = $this->container->make($controllerName->getName());
        return $controller;
    }
606617
public static function resources($resource, $controller)
    {
        $uri = strtolower(Inflector::controllerise($resource));

        // Index, show
        static::get("/{$uri}")->to("{$controller}::index");
        static::get("/{$uri}/:id")->to("{$controller}::show");

        // New
        static::get("/{$uri}/new")->to("{$controller}::new");
        static::post("/{$uri}/new")->to("{$controller}::create");

        // Edit
        static::get("/{$uri}/:id/edit")->to("{$controller}::edit");
        static::post("/{$uri}/:id/edit")->to("{$controller}::save");

        // Delete
        static::get("/{$uri}/:id/delete")->to("{$controller}::delete");
        static::post("/{$uri}/:id/delete")->to("{$controller}::destroy");
    }
1314316
public function implicitController($controller)
    {
        $container = $this->getContainer();
        $reflection = $container->getReflection()->setClass($controller);
        $methods = $reflection->getMethods('public', false, null);

        foreach ($methods as $key => $method) {
            if ($method !== '__construct') {
                list($uri, $verb, $method, $plain) = $this->getRoutesParameters($method, $controller, $reflection);
                $args = $this->getUriArguments($plain);

                if (!in_array($verb, $this->verbs)) {
                    throw new \RuntimeException("Invalid HTTP verb ($verb) exception.");
                }

                $classParam = ['controller' => $controller, 'method' => $method, 'args' => $args];

                $this->handleRoute($container, $classParam, $verb, $uri);
            }
        }
    }
649073
protected function resolveModule($controller)
    {
        $modules = $this->getModules();

        $module = get_class($controller);
        while (false !== $pos = strrpos($module, '\\')) {
            $module = substr($module, 0, $pos);
            if ($modules->has($module)) {
                return $module;
            }
        }

        throw new RuntimeException(sprintf(
            'Failed to resolve the module namespace of the "%s" controller.',
            get_class($controller)
        ));
    }
1322558
private function parseCallableController($controller, $container)
    {
        $controller  = rtrim($this->namespace, "\\") . "\\" . $this->parseCallablePlaceholders($controller);

        if ($container === null) {
               return new $controller;
        } else return $container($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;
            }
        }
    }
50030
public function create(string $type) : ?Controller
    {
        if (\class_exists($type) === false) {
            return $this->fallthrough($type);
        }

        $ref = new \ReflectionClass($type);
        $ctor = $ref->getConstructor();
        if ($ctor === null || $ctor->getNumberOfParameters() === 0) {
            return new $type();
        }

        return $this->fallthrough($type);
    }
1360523
private function getPropertyDefinitionConfig($controller)
    {
        $injectableDefinitions = $this->getPropertyDefinition();

        return $this->setPropertyInjection($injectableDefinitions)
             ->getDefinitions($controller);
    }
378099
protected function getControllerActionMetadata($controller)
    {
        $controllerClass = get_class($controller[0]);

        $metadata = $this->metadataFactory->getMetadataForClass($controllerClass);

        $controllerMetadata = $metadata->getOutsideClassMetadata();

        $action_metadatas = null;
        if (array_key_exists($controller[1], $controllerMetadata->methodMetadata)) {
            $action_metadatas = $controllerMetadata->methodMetadata[$controller[1]];
        }

        return $action_metadatas;
    }
1180174
protected function setControllerLoader(Container $container): callable
    {
        return $container->protect(function (string $name) use ($container) {
            $parts = \explode('_', $name);
            $class = $container['config']('suit.namespaces.controller', '\\App\\Controller\\');
            foreach ($parts as $part) {
                $class .= \ucfirst($part);
            }
            if (!$container->has('controller_'.$class)) {
                $container['controller_'.$class] = function ($container) use ($class) {
                    return new $class($container);
                };
            }

            return $container['controller_'.$class];
        });
    }
755666
public function generate($controller)
    {
        if (!$controller instanceof Controller) {
            $controller = new $controller('', null);
        }
        $this->controller = get_class($controller);
        $this->admin = $controller->admin;
        $this->title = $controller->name;
        $this->description = $controller->description;
    }
343823
public function handleController($controller, $method)
    {
        if($this->app->findController($controller)) {
            $controllerClass = "App\\Controller\\".$controller;
            $this->controller = new $controllerClass();
        }
        if($this->app->hasMethod($this->controller, $method)) {
            self::$instance = $this;
            ob_start();
            $return = $this->controller->$method();
            $output = ob_get_clean();
            self::$instance = null;
        }
        if($return !== null) {
            //handle returned value
        }
        $output = $output ?: null;
        return $output;
    }
845206
protected function makeController($controller)
    {

        if (!$this->creator) {
            return $this->container->make($controller);
        }

        return $this->creator->createController($controller, $this->getPage());

    }
661272
public static function build($controller)
    {
        $routes = array();
        $actions = self::parseActionMethods($controller);

        foreach ($actions as $actionName => $actionInfo) {
            list($annotations, $meta) = $actionInfo;

            if (isset($annotations['Route'])) {
                $path = $annotations['Route'];
            } else {
                if ($actionName === 'indexAction') {
                    $path = '';
                } else {
                    $path = self::translatePath($actionName); // '/' . preg_replace_callback('/[A-Z]/', function($matches) {
                }
            }

            $route = array($path, $actionName);

            if (isset($annotations['Method'])) {
                $route[] = array('method' => Mux::convertRequestMethodConstant($annotations['Method']));
            } else {
                $route[] = array();
            }
            $routes[] = $route;
        }

        return $routes;
    }
348966
public function setControllerData($controller)
    {
        if (is_string($controller)) {
            $controller = $this->app->normalizeClassName($controller, 'Data');
        } elseif (!$controller instanceof Controller_Data) {
            throw $this->exception('Inappropriate Controller. Must extend Controller_Data');
        }
        $this->controller = $this->setController($controller);

        return $this->controller;
    }
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);
    }