1
0
mirror of synced 2025-02-02 21:41:45 +03:00

return check EventManager

This commit is contained in:
Peter Gribanov 2016-06-08 12:24:41 +03:00
parent c0a87597fa
commit fa7799cec1
2 changed files with 13 additions and 0 deletions

View File

@ -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;
}

View File

@ -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
*