Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit da4cee2317157069c19590d7c12abaf5dc5d1b0c 2 parents 114c34f + 4b0cdde
@fabpot fabpot authored
View
17 src/Symfony/Component/Validator/Tests/ValidatorFactoryTest.php
@@ -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();
}
/**
View
6 src/Symfony/Component/Validator/ValidatorFactory.php
@@ -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());
}
View
2  src/Symfony/Component/Validator/composer.json
@@ -17,7 +17,6 @@
],
"require": {
"php": ">=5.3.3",
- "doctrine/common": ">=2.1,<2.3"
},
"require-dev": {
"symfony/http-foundation": "2.1.*",
@@ -25,6 +24,7 @@
"symfony/yaml": "2.1.*"
},
"suggest": {
+ "doctrine/common": ">=2.1,<2.3",
"symfony/http-foundation": "self.version",
"symfony/yaml": "self.version"
},
Please sign in to comment.
Something went wrong with that request. Please try again.