1
0
mirror of synced 2025-01-18 22:41:43 +03:00

moved exception constructors out of UoW

This commit is contained in:
flip111 2015-01-13 10:12:14 +01:00 committed by Marco Pivetta
parent b120dafb70
commit 88e071d22d

View File

@ -731,7 +731,7 @@ class UnitOfWork implements PropertyChangedListener
try {
$this->computeAssociationChanges($assoc, $val);
} catch (\Exception $ex) {
throw new Exception('Expected an Object for relation '.get_class($entity).'::'.$assoc['fieldName'].' got '.gettype($ex->value).' '.var_export($ex->value, true).' instead.');
throw ORMInvalidArgumentException::invalidAssociation($entity, $assoc['fieldName'], $ex->value);
}
if ( ! isset($this->entityChangeSets[$oid]) &&
@ -834,10 +834,8 @@ class UnitOfWork implements PropertyChangedListener
$targetClass = $this->em->getClassMetadata($assoc['targetEntity']);
foreach ($unwrappedValue as $key => $entry) {
if (! is_object($entry)) {
$ex = new \Exception(gettype($entry) . ' ' . var_export($entry, true).' is not an Object.');
$ex->value = $entry;
throw $ex;
if (! ($entry instanceof $assoc['targetEntity']))) {
throw ORMInvalidArgumentException::invalidAssociation($entry);
}
$state = $this->getEntityState($entry, self::STATE_NEW);