예제 #1
0
 /**
  * Constructor
  *
  * @param \Cake\ORM\Entity $entity Entity
  * @param int $code code to report to client
  */
 public function __construct(Entity $entity, $code = 422)
 {
     $this->_validationErrors = array_filter((array) $entity->errors());
     $flat = Hash::flatten($this->_validationErrors);
     $errorCount = $this->_validationErrorCount = count($flat);
     $this->message = __dn('crud', 'A validation error occurred', '{0} validation errors occurred', $errorCount, [$errorCount]);
     parent::__construct($this->message, $code);
 }
예제 #2
0
 /**
  * Constructor
  *
  * For a list of supported status codes see:
  * http://api.cakephp.org/3.0/class-Cake.Network.Response.html#$_statusCodes
  *
  * @param string $message Containing error message
  * @param array $errors Array with validation errors.
  * @param int $code Status code, defaults to 412
  * @return void
  */
 public function __construct($message, $errors = null, $code = 412)
 {
     if (empty($message)) {
         $message = 'RestFUL Error';
     }
     if (is_array($errors)) {
         $this->_errors = $errors;
     }
     parent::__construct($message, $code);
 }
 /**
  * Constructor
  *
  * @param array $errors Array with validation errors.
  * @param int $code Status code, defaults to 412
  */
 public function __construct($errors, $code = 412)
 {
     $message = "Data Validation Error";
     $this->_validationErrors = $errors;
     parent::__construct($message, $code);
 }