return check EventManager
This commit is contained in:
parent
c0a87597fa
commit
fa7799cec1
@ -851,6 +851,7 @@ use Doctrine\Common\Util\ClassUtils;
|
||||
* @return Connection
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws ORMException
|
||||
*/
|
||||
protected static function createConnection($connection, Configuration $config, EventManager $eventManager = null)
|
||||
{
|
||||
@ -862,6 +863,10 @@ use Doctrine\Common\Util\ClassUtils;
|
||||
throw new \InvalidArgumentException("Invalid argument: " . $connection);
|
||||
}
|
||||
|
||||
if ($eventManager !== null && $connection->getEventManager() !== $eventManager) {
|
||||
throw ORMException::mismatchedEventManager();
|
||||
}
|
||||
|
||||
return $connection;
|
||||
}
|
||||
|
||||
|
@ -154,6 +154,14 @@ class ORMException extends Exception
|
||||
return new self("'$mode' is an invalid hydration mode.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ORMException
|
||||
*/
|
||||
public static function mismatchedEventManager()
|
||||
{
|
||||
return new self("Cannot use different EventManager instances for EntityManager and Connection.");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $methodName
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user