示例#1
0
 /**
  * Validates that all required files were passed in
  * @param bool $isCreating
  * @return void
  * @throws ValidationException
  */
 private function validateAllRequired($isCreating)
 {
     foreach ($this->getFiles() as $file) {
         if (!$file->isUsed()) {
             if ($isCreating ? $file->isRequiredOnCreate() : $file->isRequiredOnUpdate()) {
                 $this->getEntity()->appendMessage(new Message('Missing the required file of: ' . $file->getName()));
             }
         }
     }
     if ($this->getEntity()->validationHasFailed() == true) {
         $validationException = new ValidationException();
         $validationException->setEntity($this->getEntity());
         throw $validationException;
     }
 }
示例#2
0
 /**
  * Handles exceptions from validations
  *
  * @param ValidationException $e
  * @param int $errorCode
  *
  * @return void
  */
 protected function handleValidationError(ValidationException $e, $errorCode = 409)
 {
     $entity = $e->getEntity();
     foreach ($entity->getMessages() as $message) {
         $this->addError(new Exception($message->getMessage(), $errorCode));
     }
 }