2012-11-26 04:03:46 +04:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION); HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE); ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* This software consists of voluntary contributions made by many individuals
|
|
|
|
* and is licensed under the MIT license. For more information, see
|
|
|
|
* <http://www.doctrine-project.org>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Doctrine\ORM;
|
|
|
|
|
|
|
|
use Doctrine\Common\Persistence\ObjectManager;
|
|
|
|
use Doctrine\ORM\Query\ResultSetMapping;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* EntityManager interface
|
|
|
|
*
|
|
|
|
* @since 2.4
|
2015-01-17 00:50:52 +03:00
|
|
|
* @author Lars Strojny <lars@strojny.net>
|
|
|
|
*
|
|
|
|
* @method Mapping\ClassMetadata getClassMetadata($className)
|
2012-11-26 04:03:46 +04:00
|
|
|
*/
|
|
|
|
interface EntityManagerInterface extends ObjectManager
|
|
|
|
{
|
2013-02-14 02:42:13 +04:00
|
|
|
/**
|
2013-12-17 00:55:54 +04:00
|
|
|
* Returns the cache API for managing the second level cache regions or NULL if the cache is not enabled.
|
2013-02-14 02:42:13 +04:00
|
|
|
*
|
|
|
|
* @return \Doctrine\ORM\Cache|null
|
|
|
|
*/
|
|
|
|
public function getCache();
|
|
|
|
|
2013-12-10 17:18:27 +04:00
|
|
|
/**
|
|
|
|
* Gets the database connection object used by the EntityManager.
|
|
|
|
*
|
|
|
|
* @return \Doctrine\DBAL\Connection
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function getConnection();
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets an ExpressionBuilder used for object-oriented construction of query expressions.
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
*
|
|
|
|
* <code>
|
|
|
|
* $qb = $em->createQueryBuilder();
|
|
|
|
* $expr = $em->getExpressionBuilder();
|
|
|
|
* $qb->select('u')->from('User', 'u')
|
|
|
|
* ->where($expr->orX($expr->eq('u.id', 1), $expr->eq('u.id', 2)));
|
|
|
|
* </code>
|
|
|
|
*
|
|
|
|
* @return \Doctrine\ORM\Query\Expr
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function getExpressionBuilder();
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Starts a transaction on the underlying database connection.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function beginTransaction();
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Executes a function in a transaction.
|
|
|
|
*
|
|
|
|
* The function gets passed this EntityManager instance as an (optional) parameter.
|
|
|
|
*
|
|
|
|
* {@link flush} is invoked prior to transaction commit.
|
|
|
|
*
|
|
|
|
* If an exception occurs during execution of the function or flushing or transaction commit,
|
|
|
|
* the transaction is rolled back, the EntityManager closed and the exception re-thrown.
|
|
|
|
*
|
|
|
|
* @param callable $func The function to execute transactionally.
|
|
|
|
*
|
|
|
|
* @return mixed The non-empty value returned from the closure or true instead.
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function transactional($func);
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Commits a transaction on the underlying database connection.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function commit();
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs a rollback on the underlying database connection.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function rollback();
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new Query object.
|
|
|
|
*
|
|
|
|
* @param string $dql The DQL string.
|
|
|
|
*
|
2013-12-10 18:08:53 +04:00
|
|
|
* @return Query
|
2013-12-10 17:18:27 +04:00
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function createQuery($dql = '');
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a Query from a named query.
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
*
|
2013-12-10 18:08:53 +04:00
|
|
|
* @return Query
|
2013-12-10 17:18:27 +04:00
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function createNamedQuery($name);
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a native SQL query.
|
|
|
|
*
|
|
|
|
* @param string $sql
|
|
|
|
* @param ResultSetMapping $rsm The ResultSetMapping to use.
|
|
|
|
*
|
|
|
|
* @return NativeQuery
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function createNativeQuery($sql, ResultSetMapping $rsm);
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a NativeQuery from a named native query.
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
*
|
2013-12-10 18:08:53 +04:00
|
|
|
* @return NativeQuery
|
2013-12-10 17:18:27 +04:00
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function createNamedNativeQuery($name);
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a QueryBuilder instance
|
|
|
|
*
|
|
|
|
* @return QueryBuilder
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function createQueryBuilder();
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a reference to the entity identified by the given type and identifier
|
|
|
|
* without actually loading it, if the entity is not yet loaded.
|
|
|
|
*
|
|
|
|
* @param string $entityName The name of the entity type.
|
|
|
|
* @param mixed $id The entity identifier.
|
|
|
|
*
|
|
|
|
* @return object The entity reference.
|
|
|
|
*
|
|
|
|
* @throws ORMException
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function getReference($entityName, $id);
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a partial reference to the entity identified by the given type and identifier
|
|
|
|
* without actually loading it, if the entity is not yet loaded.
|
|
|
|
*
|
|
|
|
* The returned reference may be a partial object if the entity is not yet loaded/managed.
|
|
|
|
* If it is a partial object it will not initialize the rest of the entity state on access.
|
|
|
|
* Thus you can only ever safely access the identifier of an entity obtained through
|
|
|
|
* this method.
|
|
|
|
*
|
|
|
|
* The use-cases for partial references involve maintaining bidirectional associations
|
|
|
|
* without loading one side of the association or to update an entity without loading it.
|
|
|
|
* Note, however, that in the latter case the original (persistent) entity data will
|
|
|
|
* never be visible to the application (especially not event listeners) as it will
|
|
|
|
* never be loaded in the first place.
|
|
|
|
*
|
|
|
|
* @param string $entityName The name of the entity type.
|
|
|
|
* @param mixed $identifier The entity identifier.
|
|
|
|
*
|
|
|
|
* @return object The (partial) entity reference.
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function getPartialReference($entityName, $identifier);
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Closes the EntityManager. All entities that are currently managed
|
|
|
|
* by this EntityManager become detached. The EntityManager may no longer
|
|
|
|
* be used after it is closed.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function close();
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a copy of the given entity. Can create a shallow or a deep copy.
|
|
|
|
*
|
|
|
|
* @param object $entity The entity to copy.
|
|
|
|
* @param boolean $deep FALSE for a shallow copy, TRUE for a deep copy.
|
|
|
|
*
|
|
|
|
* @return object The new entity.
|
|
|
|
*
|
|
|
|
* @throws \BadMethodCallException
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function copy($entity, $deep = false);
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Acquire a lock on the given entity.
|
|
|
|
*
|
|
|
|
* @param object $entity
|
|
|
|
* @param int $lockMode
|
|
|
|
* @param int|null $lockVersion
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*
|
|
|
|
* @throws OptimisticLockException
|
|
|
|
* @throws PessimisticLockException
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function lock($entity, $lockMode, $lockVersion = null);
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the EventManager used by the EntityManager.
|
|
|
|
*
|
|
|
|
* @return \Doctrine\Common\EventManager
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function getEventManager();
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the Configuration used by the EntityManager.
|
|
|
|
*
|
2013-12-10 18:08:53 +04:00
|
|
|
* @return Configuration
|
2013-12-10 17:18:27 +04:00
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function getConfiguration();
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the Entity manager is open or closed.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function isOpen();
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the UnitOfWork used by the EntityManager to coordinate operations.
|
|
|
|
*
|
2013-12-10 18:08:53 +04:00
|
|
|
* @return UnitOfWork
|
2013-12-10 17:18:27 +04:00
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function getUnitOfWork();
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a hydrator for the given hydration mode.
|
|
|
|
*
|
|
|
|
* This method caches the hydrator instances which is used for all queries that don't
|
|
|
|
* selectively iterate over the result.
|
|
|
|
*
|
|
|
|
* @deprecated
|
|
|
|
*
|
|
|
|
* @param int $hydrationMode
|
|
|
|
*
|
|
|
|
* @return \Doctrine\ORM\Internal\Hydration\AbstractHydrator
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function getHydrator($hydrationMode);
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new instance for the given hydration mode.
|
|
|
|
*
|
|
|
|
* @param int $hydrationMode
|
|
|
|
*
|
|
|
|
* @return \Doctrine\ORM\Internal\Hydration\AbstractHydrator
|
|
|
|
*
|
|
|
|
* @throws ORMException
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function newHydrator($hydrationMode);
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the proxy factory used by the EntityManager to create entity proxies.
|
|
|
|
*
|
2013-12-10 18:08:53 +04:00
|
|
|
* @return \Doctrine\ORM\Proxy\ProxyFactory
|
2013-12-10 17:18:27 +04:00
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function getProxyFactory();
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the enabled filters.
|
|
|
|
*
|
2013-12-10 18:08:53 +04:00
|
|
|
* @return \Doctrine\ORM\Query\FilterCollection The active filter collection.
|
2013-12-10 17:18:27 +04:00
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function getFilters();
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether the state of the filter collection is clean.
|
|
|
|
*
|
|
|
|
* @return boolean True, if the filter collection is clean.
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function isFiltersStateClean();
|
2013-12-10 17:18:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether the Entity Manager has filters.
|
|
|
|
*
|
|
|
|
* @return boolean True, if the EM has a filter collection.
|
|
|
|
*/
|
2012-11-26 04:03:46 +04:00
|
|
|
public function hasFilters();
|
|
|
|
}
|