Пример #1
0
 /**
  * {@inheritDoc}
  */
 public function loadClassMetadata(ClassMetadata $metadata)
 {
     if (is_null($this->classes)) {
         $this->classes = array();
         $xml = $this->parseFile($this->file);
         foreach ($xml->class as $class) {
             $this->classes[(string) $class['name']] = $class;
         }
     }
     if (isset($this->classes[$metadata->getClassName()])) {
         $xml = $this->classes[$metadata->getClassName()];
         foreach ($this->parseConstraints($xml->constraint) as $constraint) {
             $metadata->addConstraint($constraint);
         }
         foreach ($xml->property as $property) {
             foreach ($this->parseConstraints($property->constraint) as $constraint) {
                 $metadata->addPropertyConstraint((string) $property['name'], $constraint);
             }
         }
         foreach ($xml->getter as $getter) {
             foreach ($this->parseConstraints($getter->constraint) as $constraint) {
                 $metadata->addGetterConstraint((string) $getter['property'], $constraint);
             }
         }
         return true;
     }
     return false;
 }
Пример #2
0
 /**
  * {@inheritDoc}
  */
 public function loadClassMetadata(ClassMetadata $metadata)
 {
     if (is_null($this->classes)) {
         $this->classes = Yaml::load($this->file);
     }
     // TODO validation
     if (isset($this->classes[$metadata->getClassName()])) {
         $yaml = $this->classes[$metadata->getClassName()];
         if (isset($yaml['constraints'])) {
             foreach ($this->parseNodes($yaml['constraints']) as $constraint) {
                 $metadata->addConstraint($constraint);
             }
         }
         if (isset($yaml['properties'])) {
             foreach ($yaml['properties'] as $property => $constraints) {
                 foreach ($this->parseNodes($constraints) as $constraint) {
                     $metadata->addPropertyConstraint($property, $constraint);
                 }
             }
         }
         if (isset($yaml['getters'])) {
             foreach ($yaml['getters'] as $getter => $constraints) {
                 foreach ($this->parseNodes($constraints) as $constraint) {
                     $metadata->addGetterConstraint($getter, $constraint);
                 }
             }
         }
         return true;
     }
     return false;
 }
Пример #3
0
 public function walkClass(ClassMetadata $metadata, $object, $group, $propertyPath)
 {
     $this->context->setCurrentClass($metadata->getClassName());
     foreach ($metadata->findConstraints($group) as $constraint) {
         $this->walkConstraint($constraint, $object, $group, $propertyPath);
     }
     if ($object !== null) {
         foreach ($metadata->getConstrainedProperties() as $property) {
             $localPropertyPath = empty($propertyPath) ? $property : $propertyPath . '.' . $property;
             $this->walkProperty($metadata, $property, $object, $group, $localPropertyPath);
         }
     }
 }