Cake\Controller\Controller::invokeAction PHP Method

invokeAction() public method

Dispatches the controller action. Checks that the action exists and isn't private.
public invokeAction ( ) : mixed
return mixed The resulting response.
    public function invokeAction()
    {
        $request = $this->request;
        if (!isset($request)) {
            throw new LogicException('No Request object configured. Cannot invoke action');
        }
        if (!$this->isAction($request->params['action'])) {
            throw new MissingActionException(['controller' => $this->name . "Controller", 'action' => $request->params['action'], 'prefix' => isset($request->params['prefix']) ? $request->params['prefix'] : '', 'plugin' => $request->params['plugin']]);
        }
        $callable = [$this, $request->params['action']];
        return call_user_func_array($callable, $request->params['pass']);
    }

Usage Example

 protected function _invoke(Controller $controller)
 {
     $result = $controller->startupProcess();
     if ($result instanceof Response) {
         return $result;
     }
     $response = $controller->invokeAction();
     if ($response !== null && !$response instanceof Response) {
         throw new LogicException('Controller actions can only Cake\\Network\\Response instances');
     }
     if (!$response && $controller->autoRender) {
         $response = $controller->render();
     } elseif (!$response) {
         $response = $controller->response;
     }
     $result = $controller->shutdownProcess();
     if ($result instanceof Response) {
         return $result;
     }
     return $response;
 }
All Usage Examples Of Cake\Controller\Controller::invokeAction