/**
  * {@inheritdoc}
  */
 public function parse(array $input)
 {
     $params = array();
     $className = $input['class'];
     $classdata = $this->factory->getClassMetadata($className);
     $properties = $classdata->getConstrainedProperties();
     foreach ($properties as $property) {
         $vparams = array();
         $pds = $classdata->getMemberMetadatas($property);
         foreach ($pds as $propdata) {
             $constraints = $propdata->getConstraints();
             foreach ($constraints as $constraint) {
                 $vparams = $this->parseConstraint($constraint, $vparams, $className);
             }
         }
         if (isset($vparams['format'])) {
             $vparams['format'] = join(', ', $vparams['format']);
         }
         foreach (array('dataType', 'readonly', 'required') as $reqprop) {
             if (!isset($vparams[$reqprop])) {
                 $vparams[$reqprop] = null;
             }
         }
         $params[$property] = $vparams;
     }
     return $params;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function hasMetadataFor($value)
 {
     $class = is_object($value) ? get_class($value) : $value;
     set_error_handler(array($this, 'handleBC'));
     $return = null !== $this->innerFactory->getClassMetadata($class);
     restore_error_handler();
     return $return;
 }
 /**
  * @param Node $node
  * @return void
  */
 public function enterNode(Node $node)
 {
     if ($node instanceof Node\Stmt\Namespace_) {
         if (isset($node->name)) {
             $this->namespace = implode('\\', $node->name->parts);
         }
         return;
     }
     if (!$node instanceof Node\Stmt\Class_) {
         return;
     }
     $name = '' === $this->namespace ? $node->name : $this->namespace . '\\' . $node->name;
     if (!class_exists($name)) {
         return;
     }
     $metadata = $this->metadataFactory instanceof ClassMetadataFactoryInterface ? $this->metadataFactory->getClassMetadata($name) : $this->metadataFactory->getMetadataFor($name);
     if (!$metadata->hasConstraints() && !count($metadata->getConstrainedProperties())) {
         return;
     }
     $this->extractFromConstraints($metadata->constraints);
     foreach ($metadata->members as $members) {
         foreach ($members as $member) {
             $this->extractFromConstraints($member->constraints);
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function hasMetadataFor($value)
 {
     $class = is_object($value) ? get_class($value) : $value;
     return null !== $this->innerFactory->getClassMetadata($class);
 }