コード例 #1
0
ファイル: RecordEntity.php プロジェクト: jwdeitch/components
 /**
  * {@inheritdoc}
  *
  * Will validate every loaded and embedded relation.
  */
 protected function validate($reset = false)
 {
     $this->nestedErrors = [];
     //Validating all compositions/accessors
     foreach ($this->fields as $field => $value) {
         //Ensuring value state
         $value = $this->getField($field);
         if (!$value instanceof ValidatesInterface) {
             continue;
         }
         if (!$value->isValid()) {
             $this->nestedErrors[$field] = $value->getErrors($reset);
         }
     }
     //We have to validate some relations before saving them
     $this->validateRelations($reset);
     parent::validate($reset);
     return empty($this->errors + $this->nestedErrors);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  *
  * Will validate every CompositableInterface instance.
  *
  * @param bool $reset
  * @throws DocumentException
  */
 protected function validate($reset = false)
 {
     $this->nestedErrors = [];
     //Validating all compositions
     foreach ($this->odmSchema[ODM::D_COMPOSITIONS] as $field) {
         $composition = $this->getField($field);
         if (!$composition instanceof CompositableInterface) {
             //Something weird.
             continue;
         }
         if (!$composition->isValid()) {
             $this->nestedErrors[$field] = $composition->getErrors($reset);
         }
     }
     parent::validate($reset);
     return empty($this->errors + $this->nestedErrors);
 }