1
0
mirror of synced 2025-03-20 06:53:55 +03:00

prevent the validator to stop with an "undefined array index"-error while validating a wrong inversedBy Attribute

This commit is contained in:
Philipp Scheit 2012-05-21 19:23:22 +03:00
parent 93fcb74f9a
commit f1571aeac3

View File

@ -152,16 +152,18 @@ class SchemaValidator
} }
// Verify inverse side/owning side match each other // Verify inverse side/owning side match each other
$targetAssoc = $targetMetadata->associationMappings[$assoc['inversedBy']]; if (array_key_exists($assoc['inversedBy'], $targetMetadata->associationMappings)) {
if ($assoc['type'] == ClassMetadataInfo::ONE_TO_ONE && $targetAssoc['type'] !== ClassMetadataInfo::ONE_TO_ONE){ $targetAssoc = $targetMetadata->associationMappings[$assoc['inversedBy']];
$ce[] = "If association " . $class->name . "#" . $fieldName . " is one-to-one, then the inversed " . if ($assoc['type'] == ClassMetadataInfo::ONE_TO_ONE && $targetAssoc['type'] !== ClassMetadataInfo::ONE_TO_ONE){
"side " . $targetMetadata->name . "#" . $assoc['inversedBy'] . " has to be one-to-one as well."; $ce[] = "If association " . $class->name . "#" . $fieldName . " is one-to-one, then the inversed " .
} else if ($assoc['type'] == ClassMetadataInfo::MANY_TO_ONE && $targetAssoc['type'] !== ClassMetadataInfo::ONE_TO_MANY){ "side " . $targetMetadata->name . "#" . $assoc['inversedBy'] . " has to be one-to-one as well.";
$ce[] = "If association " . $class->name . "#" . $fieldName . " is many-to-one, then the inversed " . } else if ($assoc['type'] == ClassMetadataInfo::MANY_TO_ONE && $targetAssoc['type'] !== ClassMetadataInfo::ONE_TO_MANY){
"side " . $targetMetadata->name . "#" . $assoc['inversedBy'] . " has to be one-to-many."; $ce[] = "If association " . $class->name . "#" . $fieldName . " is many-to-one, then the inversed " .
} else if ($assoc['type'] == ClassMetadataInfo::MANY_TO_MANY && $targetAssoc['type'] !== ClassMetadataInfo::MANY_TO_MANY){ "side " . $targetMetadata->name . "#" . $assoc['inversedBy'] . " has to be one-to-many.";
$ce[] = "If association " . $class->name . "#" . $fieldName . " is many-to-many, then the inversed " . } else if ($assoc['type'] == ClassMetadataInfo::MANY_TO_MANY && $targetAssoc['type'] !== ClassMetadataInfo::MANY_TO_MANY){
"side " . $targetMetadata->name . "#" . $assoc['inversedBy'] . " has to be many-to-many as well."; $ce[] = "If association " . $class->name . "#" . $fieldName . " is many-to-many, then the inversed " .
"side " . $targetMetadata->name . "#" . $assoc['inversedBy'] . " has to be many-to-many as well.";
}
} }
} }