1
0
mirror of synced 2025-02-20 14:13:15 +03:00

[2.0][DDC-288] Removed deprecated flush modes.

This commit is contained in:
romanb 2010-01-29 21:36:05 +00:00
parent 94d41dfbdc
commit d76096d045
3 changed files with 14 additions and 91 deletions

View File

@ -41,31 +41,6 @@ use Doctrine\Common\EventManager,
*/
class EntityManager
{
/**
* IMMEDIATE: Flush occurs automatically after each operation that issues database
* queries. No operations are queued.
* @deprecated
*/
const FLUSHMODE_IMMEDIATE = 1;
/**
* AUTO: Flush occurs automatically in the following situations:
* - Before any query executions (to prevent getting stale data)
* - On EntityManager#commit()
* @deprecated
*/
const FLUSHMODE_AUTO = 2;
/**
* COMMIT: Flush occurs automatically only on EntityManager#commit().
* @deprecated
*/
const FLUSHMODE_COMMIT = 3;
/**
* MANUAL: Flush occurs never automatically. The only way to flush is
* through EntityManager#flush().
* @deprecated
*/
const FLUSHMODE_MANUAL = 4;
/**
* The used Configuration.
*
@ -94,14 +69,6 @@ class EntityManager
*/
private $_repositories = array();
/**
* The currently used flush mode. Defaults to 'commit'.
*
* @var string
* @deprecated
*/
private $_flushMode = self::FLUSHMODE_COMMIT;
/**
* The UnitOfWork used to coordinate object-level transactions.
*
@ -187,15 +154,9 @@ class EntityManager
/**
* Commits a transaction on the underlying database connection.
*
* This causes a flush() of the EntityManager if the flush mode is set to
* AUTO or COMMIT.
*/
public function commit()
{
if ($this->_flushMode == self::FLUSHMODE_AUTO || $this->_flushMode == self::FLUSHMODE_COMMIT) {
$this->flush();
}
$this->_conn->commit();
}
@ -335,31 +296,6 @@ class EntityManager
return $entity;
}
/**
* Sets the flush mode to use.
*
* @param string $flushMode
* @deprecated
*/
public function setFlushMode($flushMode)
{
if ( ! ($flushMode >= 1 && $flushMode <= 4)) {
throw ORMException::invalidFlushMode($flushMode);
}
$this->_flushMode = $flushMode;
}
/**
* Gets the currently used flush mode.
*
* @return string
* @deprecated
*/
public function getFlushMode()
{
return $this->_flushMode;
}
/**
* Clears the EntityManager. All entities that are currently managed
* by this EntityManager become detached.
@ -399,9 +335,6 @@ class EntityManager
{
$this->_errorIfClosed();
$this->_unitOfWork->persist($object);
if ($this->_flushMode == self::FLUSHMODE_IMMEDIATE) {
$this->flush();
}
}
/**
@ -416,9 +349,6 @@ class EntityManager
{
$this->_errorIfClosed();
$this->_unitOfWork->remove($entity);
if ($this->_flushMode == self::FLUSHMODE_IMMEDIATE) {
$this->flush();
}
}
/**
@ -470,8 +400,7 @@ class EntityManager
*/
public function copy($entity, $deep = false)
{
$this->_errorIfClosed();
throw DoctrineException::notImplemented(__FUNCTION__, __CLASS__);
throw new \BadMethodCallException("Not implemented.");
}
/**
@ -575,7 +504,7 @@ class EntityManager
$this->_hydrators[$hydrationMode] = new Internal\Hydration\SingleScalarHydrator($this);
break;
default:
throw DoctrineException::invalidHydrationMode($hydrationMode);
throw ORMException::invalidHydrationMode($hydrationMode);
}
}
return $this->_hydrators[$hydrationMode];
@ -608,10 +537,10 @@ class EntityManager
$conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, ($eventManager ?: new EventManager()));
} else if ($conn instanceof Connection) {
if ($eventManager !== null && $conn->getEventManager() !== $eventManager) {
throw DoctrineException::invalidEventManager('Cannot use different EventManagers for EntityManager and Connection.');
throw ORMException::mismatchedEventManager();
}
} else {
throw DoctrineException::invalidParameter($conn);
throw new \InvalidArgumentException("Invalid argument: " . $conn);
}
return new EntityManager($conn, $config, $conn->getEventManager());

View File

@ -46,4 +46,14 @@ class ORMException extends \Exception
{
return new self("The EntityManager is closed.");
}
public static function invalidHydrationMode($mode)
{
return new self("'$mode' is an invalid hydration mode.");
}
public static function mismatchedEventManager()
{
return new self("Cannot use different EventManager instances for EntityManager and Connection.");
}
}

View File

@ -14,16 +14,6 @@ class EntityManagerTest extends \Doctrine\Tests\OrmTestCase
$this->_em = $this->_getTestEntityManager();
}
public function testSettingInvalidFlushModeThrowsException()
{
$prev = $this->_em->getFlushMode();
try {
$this->_em->setFlushMode('foobar');
$this->fail("Setting invalid flushmode did not trigger exception.");
} catch (\Doctrine\ORM\ORMException $expected) {}
$this->_em->setFlushMode($prev);
}
public function testGetConnection()
{
$this->assertType('\Doctrine\DBAL\Connection', $this->_em->getConnection());
@ -54,11 +44,6 @@ class EntityManagerTest extends \Doctrine\Tests\OrmTestCase
$this->assertType('\Doctrine\Common\EventManager', $this->_em->getEventManager());
}
public function testGetDefaultFlushMode_OnCommit()
{
$this->assertEquals(\Doctrine\ORM\EntityManager::FLUSHMODE_COMMIT, $this->_em->getFlushMode());
}
public function testCreateNativeQuery()
{
$rsm = new \Doctrine\ORM\Query\ResultSetMapping();
@ -106,7 +91,6 @@ class EntityManagerTest extends \Doctrine\Tests\OrmTestCase
array('remove'),
array('merge'),
array('refresh'),
array('copy'),
);
}