Inheritance: extends Symfony\Component\Validator\Mapping\Loader\FileLoader
 /**
  * @param ClassMetadata $meta
  */
 protected function loadMetadata(ClassMetadata $meta)
 {
     if (false !== ($configFile = $this->getConfigFile($meta->name))) {
         $loader = new YamlFileLoader($configFile);
         $loader->loadClassMetadata($meta);
     }
 }
Ejemplo n.º 2
0
 public function testLoadGroupSequenceProvider()
 {
     $loader = new YamlFileLoader(__DIR__ . '/constraint-mapping.yml');
     $metadata = new ClassMetadata('Symfony\\Component\\Validator\\Tests\\Fixtures\\GroupSequenceProviderEntity');
     $loader->loadClassMetadata($metadata);
     $expected = new ClassMetadata('Symfony\\Component\\Validator\\Tests\\Fixtures\\GroupSequenceProviderEntity');
     $expected->setGroupSequenceProvider(true);
     $this->assertEquals($expected, $metadata);
 }
Ejemplo n.º 3
0
 public function testLoadClassMetadata()
 {
     $loader = new YamlFileLoader(__DIR__ . '/constraint-mapping.yml');
     $metadata = new ClassMetadata('Symfony\\Tests\\Component\\Validator\\Fixtures\\Entity');
     $loader->loadClassMetadata($metadata);
     $expected = new ClassMetadata('Symfony\\Tests\\Component\\Validator\\Fixtures\\Entity');
     $expected->addConstraint(new NotNull());
     $expected->addConstraint(new ConstraintA());
     $expected->addConstraint(new Min(3));
     $expected->addConstraint(new Choice(array('A', 'B')));
     $expected->addConstraint(new All(array(new NotNull(), new Min(3))));
     $expected->addConstraint(new All(array('constraints' => array(new NotNull(), new Min(3)))));
     $expected->addConstraint(new Collection(array('fields' => array('foo' => array(new NotNull(), new Min(3)), 'bar' => array(new Min(5))))));
     $expected->addPropertyConstraint('firstName', new Choice(array('message' => 'Must be one of %choices%', 'choices' => array('A', 'B'))));
     $expected->addGetterConstraint('lastName', new NotNull());
     $this->assertEquals($expected, $metadata);
 }