Crud\Controller\Component\CrudComponent::execute PHP Method

execute() public method

Execute a Crud action
public execute ( string $controllerAction = null, array $args = [] ) : Response
$controllerAction string Override the controller action to execute as.
$args array List of arguments to pass to the CRUD action (Usually an ID to edit / delete).
return Cake\Network\Response
    public function execute($controllerAction = null, $args = [])
    {
        $this->_loadListeners();
        $this->_action = $controllerAction ?: $this->_action;
        $action = $this->_action;
        if (empty($args)) {
            $args = $this->_request->params['pass'];
        }
        try {
            $event = $this->trigger('beforeHandle', $this->getSubject(compact('args', 'action')));
            $response = $this->action($event->subject->action)->handle($event->subject->args);
            if ($response instanceof Response) {
                return $response;
            }
        } catch (Exception $e) {
            if (isset($e->response)) {
                return $e->response;
            }
            throw $e;
        }
        $view = null;
        $crudAction = $this->action($action);
        if (method_exists($crudAction, 'view')) {
            $view = $crudAction->view();
        }
        return $this->_controller->response = $this->_controller->render($view);
    }