/**
  * Adds validation constaints to a field according to annotations
  * 
  * @param FieldDefinition $field
  * @param array $annotations
  * @return
  */
 protected function applyFieldConstraintsFromAnnotations(FieldDefinition $field, array $annotations)
 {
     foreach ($annotations as $anno) {
         if (!$anno instanceof \Nucleus\IService\Dashboard\Validate) {
             continue;
         }
         if (strpos($anno->constraint, '\\') !== false && class_exists($anno->constraint)) {
             $className = (string) $anno->constraint;
         } else {
             $className = 'Symfony\\Component\\Validator\\Constraints\\' . $anno->constraint;
         }
         $field->addConstraint(new $className(json_decode($anno->options, true)));
     }
 }
Beispiel #2
0
 public function addField(FieldDefinition $field)
 {
     $this->fields[$field->getName()] = $field;
     return $this;
 }