Created
February 2, 2011 09:16
-
-
Save rande/807451 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Symfony/Component/Form/FieldFactory/ValidatorFieldFactoryGuesser.php b/src/Symfony/Component/Form/FieldFactory/ValidatorFieldFactoryGuesser.php | |
index 8af07d0..b4964cf 100644 | |
--- a/src/Symfony/Component/Form/FieldFactory/ValidatorFieldFactoryGuesser.php | |
+++ b/src/Symfony/Component/Form/FieldFactory/ValidatorFieldFactoryGuesser.php | |
@@ -81,14 +81,17 @@ class ValidatorFieldFactoryGuesser implements FieldFactoryGuesserInterface | |
{ | |
$guesses = array(); | |
$classMetadata = $this->metadataFactory->getClassMetadata($class); | |
- $memberMetadatas = $classMetadata->getMemberMetadatas($property); | |
- foreach ($memberMetadatas as $memberMetadata) { | |
- $constraints = $memberMetadata->getConstraints(); | |
+ if ($classMetadata->hasMemberMetadatas($property)) { | |
+ $memberMetadatas = $classMetadata->getMemberMetadatas($property); | |
- foreach ($constraints as $constraint) { | |
- if ($guess = $guessForConstraint($constraint)) { | |
- $guesses[] = $guess; | |
+ foreach ($memberMetadatas as $memberMetadata) { | |
+ $constraints = $memberMetadata->getConstraints(); | |
+ | |
+ foreach ($constraints as $constraint) { | |
+ if ($guess = $guessForConstraint($constraint)) { | |
+ $guesses[] = $guess; | |
+ } | |
} | |
} | |
} | |
diff --git a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php | |
index f9d83ff..d679f52 100644 | |
--- a/src/Symfony/Component/Validator/Mapping/ClassMetadata.php | |
+++ b/src/Symfony/Component/Validator/Mapping/ClassMetadata.php | |
@@ -208,6 +208,18 @@ class ClassMetadata extends ElementMetadata | |
} | |
/** | |
+ * return true if metadatas of members is present for the given property | |
+ * | |
+ * @param string $property The name of the property | |
+ * @return boolean | |
+ */ | |
+ public function hasMemberMetadatas($property) | |
+ { | |
+ | |
+ return array_key_exists($property, $this->members); | |
+ } | |
+ | |
+ /** | |
* Returns all metadatas of members describing the given property | |
* | |
* @param string $property The name of the property |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment