protected function handleActionInternal($method) { try { $this->Response->addHeader('Cache-Control', 'no-cache, must-revalidate, post-check=0, pre-check=0'); $this->Response->addHeader('Expires', $this->DateFactory->newLocalDate()->toRFCDate()); $handler = $this->RequestContext->getControls()->getControl('view_handler'); switch ($handler) { case 'xml': $this->Response->sendHeader('Content-Type', 'application/xml; charset="' . $this->charset . '"'); break; case 'json': default: $this->Response->sendHeader('Content-Type', 'application/json; charset="' . $this->charset . '"'); break; } parent::handleActionInternal($method); if (!is_null($this->view) && !is_string($this->view->getName())) { throw new Exception('Method [' . $method . '] failed to return a valid view, was [' . $this->view->getName() . ']'); } } catch (NonceException $ne) { $this->bindToActionDatasource(array()); //if(LOG_ENABLE) System::log(self::$logType, 'Validation Exception: ['.print_r($ve, true).']'); $this->errors->addGlobalError($ne->getCode(), 'The record you attempted to edit has expired. This is typically caused by keeping a page open for longer than 6 hours without any changes.'); echo $this->errorsResponse(); return null; } catch (ValidationException $ve) { $this->bindToActionDatasource(array()); //if(LOG_ENABLE) System::log(self::$logType, 'Validation Exception: ['.print_r($ve, true).']'); $this->errors->addErrors($ve->getErrors()->getErrors()); echo $this->errorsResponse(); return null; } catch (ActionException $ae) { $this->bindToActionDatasource(array()); //if(LOG_ENABLE) System::log(self::$logType, 'Action Exception: ['.print_r($ae, true).']'); // store error messages and error fields somewhere $this->errors->addGlobalError($ae->getCode(), $ae->getMessage()); $view = $ae->getView() ? $ae->getView() : $this->formView(); $data = $ae->getData(); $this->view = new View($view, $data); } catch (Exception $e) { $this->ErrorHandler->sendErrorEmail($e); $this->errors->addGlobalError($e->getCode(), $e->getMessage())->throwOnError(); echo $this->errorsResponse(); return null; } return true; }
protected function handleActionInternal($method) { try { parent::handleActionInternal($method); if (is_string($this->view)) { $this->view = new View($this->view); } if (!is_null($this->view) && !is_string($this->view->getName())) { throw new Exception('Method [' . $method . '] failed to return a valid view, was [' . $this->view->getName() . ']'); } } catch (ValidationException $ve) { //if(LOG_ENABLE) System::log(self::$logType, 'Validation Exception: ['.print_r($ve, true).']'); $this->errors->addErrors($ve->getErrors()->getErrors()); $this->view = new View($this->formView()); } catch (ActionException $ae) { //if(LOG_ENABLE) System::log(self::$logType, 'Action Exception: ['.print_r($ae, true).']'); // store error messages and error fields somewhere $this->errors->addGlobalError($ae->getCode(), $ae->getMessage()); $view = $ae->getView() ? $ae->getView() : $this->formView(); $data = $ae->getData(); $this->view = new View($view, $data); } return true; }