Exemplo n.º 1
0
 /**
  * Returns true if the property value into the object is validated into the object context
  *
  * @param $object object
  * @return boolean
  */
 public function validate($object)
 {
     $validated = true;
     foreach ($this->property->getAnnotations() as $annotation_name => $annotation) {
         if ($annotation instanceof Template\Property_Validator) {
             /** @var $annotation Template\Property_Validator|Property_Validate_Annotation */
             $validated_annotation = $annotation->validate($object);
             if ($annotation->valid === true) {
                 $annotation->valid = Validate::INFORMATION;
             }
             if ($annotation->valid === false) {
                 $annotation->valid = Validate::ERROR;
             }
             if (is_null($annotation->valid)) {
                 return null;
             } else {
                 if (!$validated_annotation) {
                     $this->report[] = $annotation;
                 }
                 $validated = $validated && $validated_annotation;
             }
         }
     }
     return $validated;
 }
Exemplo n.º 2
0
 /**
  * @return string
  */
 protected function buildSingle()
 {
     if (!$this->property->getType()->isMultiple() && ($user_changes = $this->property->getAnnotations('user_change'))) {
         foreach ($user_changes as $user_change) {
             $this->on_change[] = $user_change_value = str_replace([BS, '::'], SL, $user_change->value);
         }
     }
     return parent::build();
 }