1
0
mirror of synced 2025-02-13 10:49:25 +03:00

not check EventManager

This commit is contained in:
Peter Gribanov 2016-06-08 11:29:43 +03:00
parent fadd0a338f
commit 0b5b7190d7
2 changed files with 9 additions and 22 deletions

View File

@ -821,9 +821,9 @@ use Doctrine\Common\Util\ClassUtils;
/** /**
* Factory method to create EntityManager instances. * Factory method to create EntityManager instances.
* *
* @param mixed $conn An array with the connection parameters or an existing Connection instance. * @param array|Connection $conn An array with the connection parameters or an existing Connection instance.
* @param Configuration $config The Configuration instance to use. * @param Configuration $config The Configuration instance to use.
* @param EventManager $eventManager The EventManager instance to use. * @param EventManager $eventManager The EventManager instance to use.
* *
* @return EntityManager The created EntityManager. * @return EntityManager The created EntityManager.
* *
@ -844,26 +844,21 @@ use Doctrine\Common\Util\ClassUtils;
/** /**
* Factory method to create Connection instances. * Factory method to create Connection instances.
* *
* @param mixed $conn An array with the connection parameters or an existing Connection instance. * @param array|Connection $conn An array with the connection parameters or an existing Connection instance.
* @param Configuration $config The Configuration instance to use. * @param Configuration $config The Configuration instance to use.
* @param EventManager $eventManager The EventManager instance to use. * @param EventManager $eventManager The EventManager instance to use.
* *
* @return Connection * @return Connection
* *
* @throws ORMException * @throws \InvalidArgumentException
* @throws \Doctrine\DBAL\DBALException
*/ */
protected static function createConnection($conn, Configuration $config, EventManager $eventManager = null) protected static function createConnection($conn, Configuration $config, EventManager $eventManager = null)
{ {
if (is_array($conn)) { if (is_array($conn)) {
$conn = DriverManager::getConnection( return DriverManager::getConnection(
$conn, $config, ($eventManager ?: new EventManager()) $conn, $config, ($eventManager ?: new EventManager())
); );
} elseif ($conn instanceof Connection) { } elseif ( ! $conn instanceof Connection) {
if ($eventManager !== null && $conn->getEventManager() !== $eventManager) {
throw ORMException::mismatchedEventManager();
}
} else {
throw new \InvalidArgumentException("Invalid argument: " . $conn); throw new \InvalidArgumentException("Invalid argument: " . $conn);
} }

View File

@ -154,14 +154,6 @@ class ORMException extends Exception
return new self("'$mode' is an invalid hydration mode."); 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 * @param string $methodName
* *