/** * Maps a called controller action to a component method * * @return bool|\Cake\Network\Response */ public function mapAction() { $action = $this->request->params['action']; if ($this->_config['directMapping'] === true) { if (!method_exists($this, $action)) { return false; } $result = $this->{$action}(); if ($result instanceof Response) { return $result; } return $this->_controller->render($action); } if (isset($this->_config['actionMap'][$action]) && method_exists($this, $this->_config['actionMap'][$action]['method'])) { $this->{$this->_config['actionMap'][$action]['method']}(); if ($this->_redirectResponse instanceof Response) { return $this->_redirectResponse; } if (is_string($this->_config['actionMap'][$action]['view'])) { return $this->_controller->render($this->_config['actionMap'][$action]['view']); } else { return $this->response; } } return false; }
protected function _mapAction($action) { $actionMap = $this->config('actionMap'); if (isset($actionMap[$action]) && method_exists($this, $actionMap[$action]['method'])) { $this->{$actionMap[$action]['method']}(); if ($this->_redirectResponse instanceof Response) { return $this->_redirectResponse; } if (is_string($actionMap[$action]['view'])) { return $this->_controller->render($actionMap[$action]['view']); } else { return $this->response; } } return false; }