1
0
mirror of synced 2025-01-31 04:21:44 +03:00

Merge pull request #147 from asm89/assignid

Goetas: Better error handling on missing assigned id
This commit is contained in:
Benjamin Eberlei 2011-10-15 10:41:27 -07:00
commit 7f5844c209
2 changed files with 12 additions and 13 deletions

View File

@ -60,7 +60,7 @@ class AssignedGenerator extends AbstractIdGenerator
$identifier[$idField] = $value;
}
} else {
throw ORMException::entityMissingAssignedId($entity);
throw ORMException::entityMissingAssignedIdForField($entity, $idField);
}
}
} else {
@ -78,7 +78,7 @@ class AssignedGenerator extends AbstractIdGenerator
$identifier[$idField] = $value;
}
} else {
throw ORMException::entityMissingAssignedId($entity);
throw ORMException::entityMissingAssignedIdForField($entity, $idField);
}
}

View File

@ -46,15 +46,14 @@ class ORMException extends Exception
);
}
public static function entityMissingAssignedId($entity)
public static function entityMissingAssignedIdForField($entity, $field)
{
return new self("Entity of type " . get_class($entity) . " is missing an assigned ID. " .
return new self("Entity of type " . get_class($entity) . " is missing an assigned ID for field '" . $field . "'. " .
"The identifier generation strategy for this entity requires the ID field to be populated before ".
"EntityManager#persist() is called. If you want automatically generated identifiers instead " .
"you need to adjust the metadata mapping accordingly."
);
}
public static function unrecognizedField($field)
{
return new self("Unrecognized field: $field");