fix validator class metadata warning
This commit is contained in:
parent
de401fd94c
commit
e6dc155e89
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -207,6 +207,18 @@ class ClassMetadata extends ElementMetadata
|
||||
$this->members[$property][] = $metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 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
|
||||
*
|
||||
|
@ -109,6 +109,14 @@ class ClassMetadataTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($constraints, $members[0]->getConstraints());
|
||||
}
|
||||
|
||||
public function testMemberMetadatas()
|
||||
{
|
||||
$this->metadata->addPropertyConstraint('firstName', new ConstraintA());
|
||||
|
||||
$this->assertTrue($this->metadata->hasMemberMetadatas('firstName'));
|
||||
$this->assertFalse($this->metadata->hasMemberMetadatas('non_existant_field'));
|
||||
}
|
||||
|
||||
public function testMergeConstraintsKeepsPrivateMembersSeperate()
|
||||
{
|
||||
$parent = new ClassMetadata(self::PARENTCLASS);
|
||||
|
Reference in New Issue
Block a user