Permalink
Browse files

merged branch igorw/validator-suggest-doctrine-common-2.1 (PR #4290)

Commits
-------

4b0cdde [Validator] Change default of ValidatorFactory::buildDefault to exclude annotations
c7a8678 [Validator] Move doctrine/common dependency from require to suggest

Discussion
----------

[Validator] Move doctrine/common dependency from require to suggest

`doctrine/common` is only used for the annotations, so it should be made optional.

---------------------------------------------------------------------------

by travisbot at 2012-05-15T07:11:13Z

This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1334026) (merged 4b0cdde into 114c34f).
  • Loading branch information...
2 parents 114c34f + 4b0cdde commit da4cee2317157069c19590d7c12abaf5dc5d1b0c @fabpot fabpot committed May 15, 2012
@@ -80,21 +80,6 @@ public function testGetValidator()
$this->assertEquals(new Validator($metadataFactory, $validatorFactory), $validator);
}
- public function testBuildDefaultFromAnnotations()
- {
- if (!class_exists('Doctrine\Common\Annotations\AnnotationReader')) {
- $this->markTestSkipped('Annotations is required for this test');
- }
- $factory = ValidatorFactory::buildDefault();
-
- $context = new ValidatorContext();
- $context
- ->setClassMetadataFactory(new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader())))
- ->setConstraintValidatorFactory(new ConstraintValidatorFactory());
-
- $this->assertEquals(new ValidatorFactory($context), $factory);
- }
-
public function testBuildDefaultFromAnnotationsWithCustomNamespaces()
{
if (!class_exists('Doctrine\Common\Annotations\AnnotationReader')) {
@@ -178,7 +163,7 @@ public function testBuildDefaultFromMultipleLoaders()
*/
public function testBuildDefaultThrowsExceptionIfNoLoaderIsFound()
{
- ValidatorFactory::buildDefault(array(), false);
+ ValidatorFactory::buildDefault();
}
/**
@@ -98,7 +98,7 @@ class ValidatorFactory implements ValidatorContextInterface
* has neither the extension ".xml" nor
* ".yml" nor ".yaml"
*/
- static public function buildDefault(array $mappingFiles = array(), $annotations = true, $staticMethod = null)
+ static public function buildDefault(array $mappingFiles = array(), $annotations = false, $staticMethod = null)
{
$xmlMappingFiles = array();
$yamlMappingFiles = array();
@@ -126,6 +126,10 @@ static public function buildDefault(array $mappingFiles = array(), $annotations
}
if ($annotations) {
+ if (!class_exists('Doctrine\Common\Annotations\AnnotationReader')) {
+ throw new \RuntimeException('Requested a ValidatorFactory with an AnnotationLoader, but the AnnotationReader was not found. You should add Doctrine Common to your project.');
+ }
+
$loaders[] = new AnnotationLoader(new AnnotationReader());
}
@@ -17,14 +17,14 @@
],
"require": {
"php": ">=5.3.3",
- "doctrine/common": ">=2.1,<2.3"
},
"require-dev": {
"symfony/http-foundation": "2.1.*",
"symfony/locale": "2.1.*",
"symfony/yaml": "2.1.*"
},
"suggest": {
+ "doctrine/common": ">=2.1,<2.3",
"symfony/http-foundation": "self.version",
"symfony/yaml": "self.version"
},

0 comments on commit da4cee2

Please sign in to comment.