/**
  * Check validation
  *
  * @param array|object $data
  * @param object $entity
  * @return \Phalcon\Validation\Message\Group
  */
 public function checkValidation($data = null, $entity = null)
 {
     if (!$this->isValid($data, $entity)) {
         $code = \Extlib\Http\Response::CODE_NOT_ACCEPTABLE;
         throw new Exception(\Extlib\Http\Response::getMessage($code), $code, null, $this->getErrors());
     }
 }
Exemplo n.º 2
0
 /**
  * Domyslna akcja bledow
  */
 public function errorAction()
 {
     $handler = $this->getErrorHandler();
     $error = new stdClass();
     $error->details = array();
     $error->exception = $handler->exception;
     $error->code = Response::CODE_INTERNAL_SERVER_ERROR;
     $error->message = Response::getMessage($error->code);
     switch ($handler->type) {
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
             $error->code = Response::CODE_NOT_FOUND;
             $error->message = Response::getMessage($error->code);
             break;
         default:
             if ($handler->exception instanceof Extlib\Exception) {
                 $error = $this->getExceptionData($handler->exception);
             }
             break;
     }
     if (Response::CODE_INTERNAL_SERVER_ERROR <= $error->code) {
         $this->log($error->message, Zend_Log::CRIT, $handler->exception->getTraceAsString());
     }
     if ($this->getInvokeArg('displayExceptions') == true) {
         $this->view->exception = $handler->exception;
     }
     $this->view->details = $error->details;
     $this->view->message = $error->message;
     $this->view->request = $handler->request;
     $this->getResponse()->setHttpResponseCode($error->code);
     if ($this->getRequest()->isXmlHttpRequest()) {
         $this->_helper->json($error);
     }
 }