Commit dba07641 authored by jwage's avatar jwage

[2.0] Fixing exception messages for mapping fields and associations

parent bf90126e
...@@ -588,7 +588,7 @@ class ClassMetadataInfo ...@@ -588,7 +588,7 @@ class ClassMetadataInfo
public function getFieldMapping($fieldName) public function getFieldMapping($fieldName)
{ {
if ( ! isset($this->fieldMappings[$fieldName])) { if ( ! isset($this->fieldMappings[$fieldName])) {
throw MappingException::mappingNotFound($fieldName); throw MappingException::mappingNotFound($this->name, $fieldName);
} }
return $this->fieldMappings[$fieldName]; return $this->fieldMappings[$fieldName];
} }
...@@ -603,7 +603,7 @@ class ClassMetadataInfo ...@@ -603,7 +603,7 @@ class ClassMetadataInfo
public function getAssociationMapping($fieldName) public function getAssociationMapping($fieldName)
{ {
if ( ! isset($this->associationMappings[$fieldName])) { if ( ! isset($this->associationMappings[$fieldName])) {
throw MappingException::mappingNotFound($fieldName); throw MappingException::mappingNotFound($this->name, $fieldName);
} }
return $this->associationMappings[$fieldName]; return $this->associationMappings[$fieldName];
} }
...@@ -681,10 +681,10 @@ class ClassMetadataInfo ...@@ -681,10 +681,10 @@ class ClassMetadataInfo
{ {
// Check mandatory fields // Check mandatory fields
if ( ! isset($mapping['fieldName'])) { if ( ! isset($mapping['fieldName'])) {
throw MappingException::missingFieldName(); throw MappingException::missingFieldName($this->name, $mapping);
} }
if ( ! isset($mapping['type'])) { if ( ! isset($mapping['type'])) {
throw MappingException::missingType(); throw MappingException::missingType($this->name, $mapping);
} }
// Complete fieldName and columnName mapping // Complete fieldName and columnName mapping
...@@ -752,7 +752,7 @@ class ClassMetadataInfo ...@@ -752,7 +752,7 @@ class ClassMetadataInfo
public function getSingleIdentifierFieldName() public function getSingleIdentifierFieldName()
{ {
if ($this->isIdentifierComposite) { if ($this->isIdentifierComposite) {
throw DoctrineException::singleIdNotAllowedOnCompositePrimaryKey(); throw DoctrineException::singleIdNotAllowedOnCompositePrimaryKey($this->name);
} }
return $this->identifier[0]; return $this->identifier[0];
} }
...@@ -790,6 +790,16 @@ class ClassMetadataInfo ...@@ -790,6 +790,16 @@ class ClassMetadataInfo
return isset($this->fieldMappings[$fieldName]); return isset($this->fieldMappings[$fieldName]);
} }
public function hasInheritedMapping($fieldName)
{
if (isset($this->fieldMappings[$fieldName]) || isset($this->associationMappings[$fieldName]))
{
} else {
return false;
}
}
/** /**
* Gets all field mappings. * Gets all field mappings.
* *
...@@ -1086,7 +1096,7 @@ class ClassMetadataInfo ...@@ -1086,7 +1096,7 @@ class ClassMetadataInfo
public function setInheritanceType($type) public function setInheritanceType($type)
{ {
if ( ! $this->_isInheritanceType($type)) { if ( ! $this->_isInheritanceType($type)) {
throw MappingException::invalidInheritanceType($type); throw MappingException::invalidInheritanceType($this->name, $type);
} }
$this->inheritanceType = $type; $this->inheritanceType = $type;
} }
...@@ -1101,6 +1111,17 @@ class ClassMetadataInfo ...@@ -1101,6 +1111,17 @@ class ClassMetadataInfo
return isset($this->fieldMappings[$fieldName]['inherited']); return isset($this->fieldMappings[$fieldName]['inherited']);
} }
/**
* Checks whether a mapped association field is inherited from a superclass.
*
* @param string $fieldName
* @return boolean TRUE if the field is inherited, FALSE otherwise.
*/
public function isInheritedAssociation($fieldName)
{
return isset($this->inheritedAssociationFields[$fieldName]);
}
/** /**
* Sets the name of the primary table the class is mapped to. * Sets the name of the primary table the class is mapped to.
* *
...@@ -1192,7 +1213,7 @@ class ClassMetadataInfo ...@@ -1192,7 +1213,7 @@ class ClassMetadataInfo
{ {
$this->_validateAndCompleteFieldMapping($mapping); $this->_validateAndCompleteFieldMapping($mapping);
if (isset($this->fieldMappings[$mapping['fieldName']])) { if (isset($this->fieldMappings[$mapping['fieldName']])) {
throw MappingException::duplicateFieldMapping($mapping['fieldName']); throw MappingException::duplicateFieldMapping($this->name, $mapping['fieldName']);
} }
$this->fieldMappings[$mapping['fieldName']] = $mapping; $this->fieldMappings[$mapping['fieldName']] = $mapping;
} }
...@@ -1210,7 +1231,7 @@ class ClassMetadataInfo ...@@ -1210,7 +1231,7 @@ class ClassMetadataInfo
{ {
$sourceFieldName = $mapping->sourceFieldName; $sourceFieldName = $mapping->sourceFieldName;
if (isset($this->associationMappings[$sourceFieldName])) { if (isset($this->associationMappings[$sourceFieldName])) {
throw MappingException::duplicateFieldMapping(); throw MappingException::duplicateAssociationMapping($this->name, $sourceFieldName);
} }
$this->associationMappings[$sourceFieldName] = $mapping; $this->associationMappings[$sourceFieldName] = $mapping;
if ($owningClassName !== null) { if ($owningClassName !== null) {
...@@ -1304,7 +1325,7 @@ class ClassMetadataInfo ...@@ -1304,7 +1325,7 @@ class ClassMetadataInfo
{ {
$sourceFieldName = $assocMapping->sourceFieldName; $sourceFieldName = $assocMapping->sourceFieldName;
if (isset($this->associationMappings[$sourceFieldName])) { if (isset($this->associationMappings[$sourceFieldName])) {
throw MappingException::duplicateFieldMapping(); throw MappingException::duplicateFieldMapping($this->name, $sourceFieldName);
} }
$this->associationMappings[$sourceFieldName] = $assocMapping; $this->associationMappings[$sourceFieldName] = $assocMapping;
$this->_registerMappingIfInverse($assocMapping); $this->_registerMappingIfInverse($assocMapping);
...@@ -1418,7 +1439,7 @@ class ClassMetadataInfo ...@@ -1418,7 +1439,7 @@ class ClassMetadataInfo
{ {
if ($columnDef !== null) { if ($columnDef !== null) {
if ( ! isset($columnDef['name'])) { if ( ! isset($columnDef['name'])) {
throw new MappingException("'name' attribute is mandatory for discriminator columns."); throw MappingException::nameIsMandatoryForDiscriminatorColumns($this->name, $columnDef);
} }
if ( ! isset($columnDef['fieldName'])) { if ( ! isset($columnDef['fieldName'])) {
$columnDef['fieldName'] = $columnDef['name']; $columnDef['fieldName'] = $columnDef['name'];
...@@ -1614,7 +1635,7 @@ class ClassMetadataInfo ...@@ -1614,7 +1635,7 @@ class ClassMetadataInfo
} else if ($mapping['type'] == 'datetime') { } else if ($mapping['type'] == 'datetime') {
$mapping['default'] = 'CURRENT_TIMESTAMP'; $mapping['default'] = 'CURRENT_TIMESTAMP';
} else { } else {
throw DoctrineException::unsupportedOptimisticLockingType($mapping['type']); throw DoctrineException::unsupportedOptimisticLockingType($this->name, $mapping['fieldName'], $mapping['type']);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment