Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the initializeObject method in the EntityManager #150

Merged
merged 1 commit into from
Oct 16, 2011
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 20 additions & 8 deletions lib/Doctrine/ORM/EntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected function __construct(Connection $conn, Configuration $config, EventMan
$this->metadataFactory = new $metadataFactoryClassName;
$this->metadataFactory->setEntityManager($this);
$this->metadataFactory->setCacheDriver($this->config->getMetadataCacheImpl());

$this->unitOfWork = new UnitOfWork($this);
$this->proxyFactory = new ProxyFactory($this,
$config->getProxyDir(),
Expand Down Expand Up @@ -203,18 +203,18 @@ public function beginTransaction()
public function transactional(Closure $func)
{
$this->conn->beginTransaction();

try {
$return = $func($this);

$this->flush();
$this->conn->commit();

return $return ?: true;
} catch (Exception $e) {
$this->close();
$this->conn->rollback();

throw $e;
}
}
Expand Down Expand Up @@ -244,7 +244,7 @@ public function rollback()
*
* The class name must be the fully-qualified class name without a leading backslash
* (as it is returned by get_class($obj)) or an aliased class name.
*
*
* Examples:
* MyProject\Domain\User
* sales:PriceRequest
Expand Down Expand Up @@ -450,7 +450,7 @@ public function close()
*
* The entity will be entered into the database at or before transaction
* commit or as a result of the flush operation.
*
*
* NOTE: The persist operation always considers entities that are not yet known to
* this EntityManager as NEW. Do not pass detached entities to the persist operation.
*
Expand Down Expand Up @@ -633,7 +633,7 @@ private function errorIfClosed()

/**
* Check if the Entity manager is open or closed.
*
*
* @return bool
*/
public function isOpen()
Expand Down Expand Up @@ -714,6 +714,18 @@ public function getProxyFactory()
return $this->proxyFactory;
}

/**
* Helper method to initialize a lazy loading proxy or persistent collection.
*
* This method is a no-op for other objects
*
* @param object $obj
*/
public function initializeObject($obj)
{
$this->unitOfWork->initializeObject($obj);
}

/**
* Factory method to create EntityManager instances.
*
Expand Down