#1240 DDC-3479 - Using a static proxy constructor rather than the default constructor
This commit is contained in:
parent
66c556fbfd
commit
fc72b41953
@ -28,13 +28,16 @@ namespace Doctrine\ORM;
|
||||
class EntityNotFoundException extends ORMException
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
* Static constructor.
|
||||
*
|
||||
* @param string $className
|
||||
* @param string[] $id
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function __construct($className, array $id = array())
|
||||
public static function fromClassNameAndIdentifier($className, array $id)
|
||||
{
|
||||
|
||||
$ids = array();
|
||||
|
||||
foreach ($id as $key => $value) {
|
||||
@ -42,7 +45,7 @@ class EntityNotFoundException extends ORMException
|
||||
}
|
||||
|
||||
|
||||
parent::__construct(
|
||||
return new self(
|
||||
'Entity of type \'' . $className . '\'' . ($ids ? ' for IDs ' . implode(', ', $ids) : '') . ' was not found'
|
||||
);
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ class ProxyFactory extends AbstractProxyFactory
|
||||
$proxy->__setCloner($cloner);
|
||||
$proxy->__setInitialized(false);
|
||||
|
||||
throw new EntityNotFoundException(
|
||||
throw EntityNotFoundException::fromClassNameAndIdentifier(
|
||||
$classMetadata->getName(),
|
||||
$identifierFlattener->flattenIdentifier($classMetadata, $identifier)
|
||||
);
|
||||
@ -190,7 +190,7 @@ class ProxyFactory extends AbstractProxyFactory
|
||||
$proxy->__setCloner($cloner);
|
||||
$proxy->__setInitialized(false);
|
||||
|
||||
throw new EntityNotFoundException(
|
||||
throw EntityNotFoundException::fromClassNameAndIdentifier(
|
||||
$classMetadata->getName(),
|
||||
$identifierFlattener->flattenIdentifier($classMetadata, $identifier)
|
||||
);
|
||||
@ -225,7 +225,7 @@ class ProxyFactory extends AbstractProxyFactory
|
||||
$original = $entityPersister->loadById($identifier);
|
||||
|
||||
if (null === $original) {
|
||||
throw new EntityNotFoundException(
|
||||
throw EntityNotFoundException::fromClassNameAndIdentifier(
|
||||
$classMetadata->getName(),
|
||||
$identifierFlattener->flattenIdentifier($classMetadata, $identifier)
|
||||
);
|
||||
|
@ -1843,7 +1843,10 @@ class UnitOfWork implements PropertyChangedListener
|
||||
// If the identifier is ASSIGNED, it is NEW, otherwise an error
|
||||
// since the managed entity was not found.
|
||||
if ( ! $class->isIdentifierNatural()) {
|
||||
throw new EntityNotFoundException($class->getName(), $this->identifierFlattener->flattenIdentifier($class, $id));
|
||||
throw EntityNotFoundException::fromClassNameAndIdentifier(
|
||||
$class->getName(),
|
||||
$this->identifierFlattener->flattenIdentifier($class, $id)
|
||||
);
|
||||
}
|
||||
|
||||
$managedCopy = $this->newInstance($class);
|
||||
|
Loading…
Reference in New Issue
Block a user