execController

@param Controller $controller
@param string $action
@param array $ags
@return void
516593
private static function execController($controller,$action,$args){
        $controller = new $controller();
        $controller->doAction($action,$args);
    }
1070174
public function initialize(Controller $controller) {
        $autoLogin = (array) Configure::read('AutoLogin');

        // Is debug enabled?
        $this->_debug = (!empty($autoLogin['ips']) && in_array(env('REMOTE_ADDR'), (array) $autoLogin['ips']));
    }
649690
public function triggerController(string $controller, ...$args)
    {
        //extract the class and method
        list($class, $method) = explode('@', $controller, 2);

        //if the class exists
        if (class_exists($class)) {
            //instantiate it
            $instance = new $class();

            //does the method exist ?
            if (method_exists($instance, $method)) {
                call_user_func_array([$instance, $method], $args);
            }
        }

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

        $this->checkCli();
    }
174774
public function execute($actionContext) {
        $this->url = UrlHelper::action($actionContext, $this->actionName, $this->controllerName, $this->routeValues, $this->fragment);
        parent::execute($actionContext);
    }
242883
public function initCron($src, $controller, $action) {
        if (!Config::config()['user']['debug']['maintenance']) {
            $this->_routeCron($src, $controller, $action);

            if ($this->_route == true) {
                $this->_setFunction($this->request->src);
                $this->_setEvent($this->request->src);
            }
        }
    }
856367
public function runController($controller = null, $action = null, $values = array())
    {
        if($action != null && method_exists($controller, $action))
        {
            if($values != null)
            {
                call_user_func_array(array($controller, $action), $values);
            }
            else
            {
                $controller->{$action}();
            }
        }
        else
        {
            $controller;
        }
    }
61021
public static function is(string $controller, string $action): bool
    {
        return $controller == Application::route()->getControllerUrl() && $action == Application::route()->getActionUrl();
    }
381192
public function initialize(Controller $controller) {
		$this->_controller = $controller;
		if (!$this->_controller->Components->loaded('RequestHandler')) {
			$this->_controller->RequestHandler = $this->_controller->Components->load('RequestHandler');
			$this->_controller->RequestHandler->initialize($this->_controller);
		}
		if (empty($this->modelName)) {
			$this->_model = $this->_controller->{$this->_controller->modelClass};
		} else {
			$this->_model = ClassRegistry::init($this->modelName, true);
			if ($this->_model === false) {
				throw new InternalErrorException(__d('view_extension', 'Invalid name of target model for component'));
			}
		}
		if (!$this->_model->Behaviors->loaded('Tree')) {
			throw new InternalErrorException(__d('view_extension', 'Tree behavior is not loaded'));
		}
	}
523884
public function startup(Controller $controller) {
		if (!$this->_controller->ViewExtension->isHtml()) {
			return;
		}

		$this->_setConfigVar($controller);
	}
556099
protected function configureController(Controller $controller)
    {
        parent::configureController($controller);
        $controller[] = new Entity($this->entityName);
    }
1247881
private function executeAction(string $action)
    {
        list($controller, $method) = explode('@', $action);

        $class = '\App\Controllers\\'.ucfirst($controller).'Controller';

        if (!class_exists($class)) {
            throw new ExceptionHandler('Class "'.$class.'" not found.');
        }

        $controllerInstantiate = new $class();

        if (!method_exists($controllerInstantiate, $method)) {
            throw new ExceptionHandler('Method "'.$method.'" not found in '.$class.'.');
        }

        return call_user_func_array([new $controllerInstantiate, $method], []);
    }
704274
public function callController($route, array $arguments = array())
    {
        $route = $this->set($route, $arguments);
        $callback = Handler::get($route, null, 'controller');

        if (!$callback[0] instanceof Controller) {
            throw new LogicException('Controller must be instance of \gplcart\core\Controller');
        }

        call_user_func_array($callback, $route['arguments']);

        // We should never get here as the page callback must abort the script execution
        throw new LogicException('An error occurred while processing the route');
    }
741006
public function onKernelController(FilterControllerEvent $event): void
    {
        $controller = $event->getController();
        if (\is_array($controller)) {
            [$controller] = $controller; // Ignoring action
        }
        if (!$controller instanceof AdminInjectableInterface && !$controller instanceof ActionInjectableInterface) {
            return;
        }

        $request = $event->getRequest();
        if (!$request->attributes->has('_admin')) {
            $routeName = $request->attributes->get('_route');

            $m = "Missing request attribute '_admin' for route {$routeName}, this means you declared";
            $m .= ' this route outside the admin configuration, please use the admin configuration';
            throw new \LogicException($m);
        }
        $admin = $request->attributes->get('_admin');
        if (!$admin instanceof Admin) {
            throw new \UnexpectedValueException('_admin request attribute is not an Admin object');
        }
        if ($controller instanceof AdminInjectableInterface) {
            $controller->setAdmin($admin);
        }

        if (!$request->attributes->has('_action')) {
            $routeName = $request->attributes->get('_route');

            $m = "Missing request attribute '_action' for route {$routeName},";
            $m .= 'this means you declared this route outside the admin configuration, please include the _action';
            $m .= 'attribute in your route definition or use the admin configuration';
            throw new \LogicException($m);
        }
        $admin->setCurrentAction($request->attributes->get('_action'));
        if ($controller instanceof ActionInjectableInterface) {
            $controller->setAction($admin->getCurrentAction());
        }
    }
454446
protected function _authRequired(Controller $controller)
    {
        $request = $controller->getRequest();
        if (is_array($this->_config['requireAuth']) &&
            !empty($this->_config['requireAuth']) &&
            $request->getData()
        ) {
            deprecationWarning('SecurityComponent::requireAuth() will be removed in 4.0.0.');
            $requireAuth = $this->_config['requireAuth'];

            if (in_array($request->getParam('action'), $requireAuth) || $requireAuth == ['*']) {
                if ($request->getData('_Token') === null) {
                    throw new AuthSecurityException('\'_Token\' was not found in request data.');
                }

                if ($this->session->check('_Token')) {
                    $tData = $this->session->read('_Token');

                    if (!empty($tData['allowedControllers']) &&
                        !in_array($request->getParam('controller'), $tData['allowedControllers'])) {
                        throw new AuthSecurityException(
                            sprintf(
                                'Controller \'%s\' was not found in allowed controllers: \'%s\'.',
                                $request->getParam('controller'),
                                implode(', ', (array)$tData['allowedControllers'])
                            )
                        );
                    }
                    if (!empty($tData['allowedActions']) &&
                        !in_array($request->getParam('action'), $tData['allowedActions'])
                    ) {
                        throw new AuthSecurityException(
                            sprintf(
                                'Action \'%s::%s\' was not found in allowed actions: \'%s\'.',
                                $request->getParam('controller'),
                                $request->getParam('action'),
                                implode(', ', (array)$tData['allowedActions'])
                            )
                        );
                    }
                } else {
                    throw new AuthSecurityException('\'_Token\' was not found in session.');
                }
            }
        }

        return true;
    }
580395
private function _callAction(Controller $controller, $action, $error)
    {
        if ($error) {
            $method = $this->actionChain->actionNameStrategy($action . '_' . $error);
        } else {
            $method = $this->actionChain->actionNameStrategy($action);
        }
        if (method_exists($controller, $method)) {
            return $controller->$method();
        } else {
            return $error;
        }
    }
168059
public function invokeAction($controller, $action, $params)
    {
        $actionMethod = $action . 'Action';

        if (!method_exists($controller, $actionMethod)) {
            throw new NotFoundActionException([
                '`:controller:::action` method does not exist',
                'action' => $actionMethod,
                'controller' => get_class($controller)
            ]);
        }

        $this->eventsManager->fireEvent('request:authorize', $this);

        $this->eventsManager->fireEvent('request:validate', $this, ['controller' => get_class($controller), 'action' => $action]);

        $this->eventsManager->fireEvent('request:ready', $this);

        $this->eventsManager->fireEvent('request:invoke', $this, $action);

        $args = $this->_buildActionArgs($controller, $action, $params);

        switch (count($args)) {
            case 0:
                $r = $controller->$actionMethod();
                break;
            case 1:
                $r = $controller->$actionMethod($args[0]);
                break;
            case 2:
                $r = $controller->$actionMethod($args[0], $args[1]);
                break;
            case 3:
                $r = $controller->$actionMethod($args[0], $args[1], $args[2]);
                break;
            default:
                $r = call_user_func_array([$controller, $actionMethod], $args);
                break;
        }

        $this->eventsManager->fireEvent('request:invoked', $this, ['action' => $action, 'return' => $r]);

        return $r;
    }