not check EventManager
This commit is contained in:
parent
fadd0a338f
commit
0b5b7190d7
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user