|
@@ -11,9 +11,9 @@
|
|
|
|
|
|
namespace Symfony\Component\Validator\Mapping\Loader;
|
|
|
|
|
|
+use Annotations\Reader;
|
|
|
use Symfony\Component\Validator\Exception\MappingException;
|
|
|
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
|
|
-use Doctrine\Common\Annotations\AnnotationReader;
|
|
|
use Symfony\Component\Validator\Constraints\Set;
|
|
|
use Symfony\Component\Validator\Constraints\GroupSequence;
|
|
|
use Symfony\Component\Validator\Constraint;
|
|
@@ -22,18 +22,12 @@ class AnnotationLoader implements LoaderInterface
|
|
|
{
|
|
|
protected $reader;
|
|
|
|
|
|
- public function __construct(array $paths = null)
|
|
|
+ public function __construct()
|
|
|
{
|
|
|
- if (null === $paths) {
|
|
|
- $paths = array('assert' => 'Symfony\\Component\\Validator\\Constraints\\');
|
|
|
- }
|
|
|
-
|
|
|
- $this->reader = new AnnotationReader();
|
|
|
+ $this->reader = new Reader();
|
|
|
$this->reader->setAutoloadAnnotations(true);
|
|
|
-
|
|
|
- foreach ($paths as $prefix => $path) {
|
|
|
- $this->reader->setAnnotationNamespaceAlias($path, $prefix);
|
|
|
- }
|
|
|
+ $this->reader->setIgnoreNotImportedAnnotations(false);
|
|
|
+ $this->reader->setIndexByClass(false);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -46,11 +40,7 @@ class AnnotationLoader implements LoaderInterface
|
|
|
$loaded = false;
|
|
|
|
|
|
foreach ($this->reader->getClassAnnotations($reflClass) as $constraint) {
|
|
|
- if ($constraint instanceof Set) {
|
|
|
- foreach ($constraint->constraints as $constraint) {
|
|
|
- $metadata->addConstraint($constraint);
|
|
|
- }
|
|
|
- } elseif ($constraint instanceof GroupSequence) {
|
|
|
+ if ($constraint instanceof GroupSequence) {
|
|
|
$metadata->setGroupSequence($constraint->groups);
|
|
|
} elseif ($constraint instanceof Constraint) {
|
|
|
$metadata->addConstraint($constraint);
|
|
@@ -62,11 +52,7 @@ class AnnotationLoader implements LoaderInterface
|
|
|
foreach ($reflClass->getProperties() as $property) {
|
|
|
if ($property->getDeclaringClass()->getName() == $className) {
|
|
|
foreach ($this->reader->getPropertyAnnotations($property) as $constraint) {
|
|
|
- if ($constraint instanceof Set) {
|
|
|
- foreach ($constraint->constraints as $constraint) {
|
|
|
- $metadata->addPropertyConstraint($property->getName(), $constraint);
|
|
|
- }
|
|
|
- } elseif ($constraint instanceof Constraint) {
|
|
|
+ if ($constraint instanceof Constraint) {
|
|
|
$metadata->addPropertyConstraint($property->getName(), $constraint);
|
|
|
}
|
|
|
|
|
@@ -81,11 +67,7 @@ class AnnotationLoader implements LoaderInterface
|
|
|
// TODO: clean this up
|
|
|
$name = lcfirst(substr($method->getName(), 0, 3)=='get' ? substr($method->getName(), 3) : substr($method->getName(), 2));
|
|
|
|
|
|
- if ($constraint instanceof Set) {
|
|
|
- foreach ($constraint->constraints as $constraint) {
|
|
|
- $metadata->addGetterConstraint($name, $constraint);
|
|
|
- }
|
|
|
- } elseif ($constraint instanceof Constraint) {
|
|
|
+ if ($constraint instanceof Constraint) {
|
|
|
$metadata->addGetterConstraint($name, $constraint);
|
|
|
}
|
|
|
|