@param string $controller

@return array|null [$class, $method]
549219
private function detectClassAndMethod(string $controller): ?array
    {
        if (preg_match('#(.+)::([\w]+)#', $controller, $matches)) {
            $class = $matches[1];
            $method = $matches[2];
        } elseif (class_exists($controller)) {
            $class = $controller;
            $method = '__invoke';
        } else {
            if (preg_match('#(.+):([\w]+)#', $controller, $matches)) {
                $controller = $matches[1];
                $method = $matches[2];
            }

            if ($this->container->has($controller)) {
                $class = get_class($this->container->get($controller));

                if (!isset($method) && method_exists($class, '__invoke')) {
                    $method = '__invoke';
                }
            }
        }

        if (!isset($class) || !isset($method)) {
            return null;
        }

        return [$class, $method];
    }
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;
        }
    }
1360523
private function getPropertyDefinitionConfig($controller)
    {
        $injectableDefinitions = $this->getPropertyDefinition();

        return $this->setPropertyInjection($injectableDefinitions)
             ->getDefinitions($controller);
    }
574460
protected function makeController($controller)
	{
		Controller::setFilterer($this->filterer);

		return $this->container->make($controller);
	}
1213806
static function load($controller, $action = '', $params = array())
	{

		$class_name = ucfirst($controller);
		$method = $action;
		$tc = "Controller\\" . $class_name;
		if (!class_exists($tc)) return self::er("Class $tc does not exist.");
		$this_object = new $tc($params);


		if (!method_exists($this_object, $method)) {
			return self::er("Method $method in $tc does not exist.");
		}


		if (!is_callable(array($this_object, $method))) return self::er("Method $method in $tc is not callable.");
		if (is_callable(array($this_object, "__before"))) {
			call_user_func(array($this_object, "__before"));
		}


		call_user_func(array($this_object, $method));

		if (is_callable(array($this_object, "__after"))) {
			call_user_func(array($this_object, "__after"));
		}
		return $this_object;
	}
416390
private function getControllerActionAnnotations($controller, $action)
    {
        if ($controller instanceof \Closure) {
            return $this->annotation->readFunction($controller);
        }

        return $this->annotation->readMethod($controller, $action . 'Action');
    }
615450
public function beforeRender(Controller $controller) {
		if (!class_exists('NoSql')) {
			return null;
		}

		$content = NoSql::getLogs();
		$count = 0;
		$time = 0;
		foreach ($content as $logs) {
			$count += $logs['count'];
			$time += $logs['time'];
		}

		if ($this->priority > 0) {
			if ($count === 0) {
				$this->title = __d('debug_kit_ex', '<b>%d</b> NoSql', $count);
			} else {
				$this->title = __d('debug_kit_ex', '<b>%dms / %d</b> NoSql', $time, $count);
			}
		}
		return $content;
	}
690681
public function getMiddleware($controller, $method)
    {
        if (! method_exists($controller, 'getMiddleware')) {
            return [];
        }

        return collect($controller->getMiddleware())->reject(function ($data) use ($method) {
            return static::methodExcludedByOptions($method, $data['options']);
        })->pluck('middleware')->all();
    }
201706
private function validate($controller,$app) {
        $rule = [];
        if($controller->hasProperty('_rule')) {
            $rule = $app->_rule;
        }

        $validate = null;
        if($controller->hasProperty('_validate')) {
            $validate = $app->_validate;
        }
        else {
            $rule and $validate = Validate::class;
        }

        if($validate) {
            $message = $controller->hasProperty('_message')?$app->_message:[];
            $validate = new $validate($rule,$message);
        }

        return $validate;
    }
1220952
public function getControllerClass()
    {
        $controller = array_get($this->routeParams, 'controller');
        $match      = null;
        if (!preg_match('/(.*?)(?=@|$)/', $controller, $match)) {
            return;
        }
        return $match[0];
    }
1089765
public function controller($controller_name)
    {
        // Retrieving the class and method to launch.
        if (is_null($controller_name)) {
            return null;
        }

        $parts = preg_split('/::|@/', $controller_name);

        if (count($parts) == 1) {
            $parts[1] = '__invoke';
        }

        list($class, $method) = $parts;

        if (!class_exists($class, true)) {
            $class = sprintf('%s\\%s', $this->namespaces['controller'], ucfirst($class));
        }

        $injections = $this->injector($class, $method);

        return [
            'action' => [new $class(), $method],
            'injection' => $injections
        ];
    }
856137
protected function makeController($controller)
	{
		Controller::setRouter($this->router);

		return $this->container->make($controller);
	}
1221365
protected function getRoute($controller)
    {
        $routes = $this->router->getRouteCollection()->all();
        foreach ($routes as $name => $route) {
            if ($controller === $route->getDefault('_controller')) {
                return [ $name, $route ];
            }
        }

        return null;
    }
953492
protected function getTemplate(Request $request, $controller)
    {
        if ($request->attributes->has('_template')) {
            return null;
        }

        $format    = $request->attributes->get('_format', 'html');
        $templates = [];

        if ($controllerInfo = $this->parseController($controller)) {
            $template = sprintf('%s/%s.%s.twig', $controllerInfo['name'], $controllerInfo['action'], $format);

            if ($this->templateExists($template)) {
                return $template;
            } else {
                $templates[] = $template;
            }
        }

        $route = $this->routes->get($request->attributes->get('_route'));

        if ($route && $route->hasContent()) {
            $template = sprintf('%s/%s.%s.twig', $route->getContent(), $route->isList() ? 'list' : 'show', $format);

            if ($this->templateExists($template)) {
                return $template;
            } else {
                $templates[] = $template;
            }
        }

        return array_pop($templates);
    }
1178063
protected function getActions($controller)
    {
        $actions = array_keys($controller->actions());
        $class = new \ReflectionClass($controller);
        foreach ($class->getMethods() as $method) {
            $name = $method->getName();
            if ($name !== 'actions' && $method->isPublic() && !$method->isStatic() && strpos($name, 'action') === 0) {
                $actions[] = Inflector::camel2id(substr($name, 6), '-', true);
            }
        }
        sort($actions);

        return array_unique($actions);
    }
1372849
public function getReflectionMethod(string $controller)
    {
        $callable = $this->getClassAndMethod($controller);
        if (null === $callable) {
            return null;
        }

        list($class, $method) = $callable;

        try {
            return new \ReflectionMethod($class, $method);
        } catch (\ReflectionException $e) {
            // In case we can't reflect the controller, we just
            // ignore the route
        }
    }
385142
public function makeSoftDeletesCondition($controller)
    {
        if (!$controller->withTrashed()) return [];
        return [
            'deleted_at' => [
                'type' => 'select',
                'label' => 'status',
                'options' => [
                    'exists' => 'exists',
                    'deleted' => 'deleted'
                ],
                'query' => function($query, $condition, $input) {

                    // If not deleted...
                    if (($input == 'exists' && $condition == '=') ||
                        ($input == 'deleted' && $condition == '!=')) {
                        $query->whereNull('deleted_at');

                    // If deleted...
                    } else if (($input == 'deleted' && $condition == '=') ||
                        ($input == 'exists' && $condition == '!=')) {
                        $query->whereNotNull('deleted_at');
                    }
                },
            ]
        ];
    }