abstract class EntityManagerDecorator extends ObjectManagerDecorator implements EntityManagerInterface (View source)

Base class for EntityManager decorators

Properties

protected EntityManagerInterface $wrapped

Methods

__construct(EntityManagerInterface $wrapped)

No description

Connection
getConnection()

Gets the database connection object used by the EntityManager.

getExpressionBuilder()

Gets an ExpressionBuilder used for object-oriented construction of query expressions.

getIdentifierFlattener()

Gets an IdentifierFlattener used for converting Entities into an array of identifier values.

void
beginTransaction()

Starts a transaction on the underlying database connection.

mixed
transactional(callable $func)

Executes a function in a transaction.

void
commit()

Commits a transaction on the underlying database connection.

void
rollback()

Performs a rollback on the underlying database connection.

createQuery(string $dql = '')

Creates a new Query object.

createNativeQuery(string $sql, ResultSetMapping $rsm)

Creates a native SQL query.

createQueryBuilder()

Create a QueryBuilder instance

object|GhostObjectInterface|null
getReference(string $entityName, mixed $id)

Gets a reference to the entity identified by the given type and identifier without actually loading it, if the entity is not yet loaded.

object
getPartialReference(string $entityName, mixed $identifier)

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.

void
close()

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.

void
lock(object $entity, int $lockMode, int|null $lockVersion = null)

Acquire a lock on the given entity.

find($entityName, $id, $lockMode = null, $lockVersion = null)

{@inheritdoc}

flush()

{@inheritdoc}

EventManager
getEventManager()

Gets the EventManager used by the EntityManager.

getConfiguration()

Gets the Configuration used by the EntityManager.

bool
isOpen()

Check if the Entity manager is open or closed.

getUnitOfWork()

Gets the UnitOfWork used by the EntityManager to coordinate operations.

getHydrator(int $hydrationMode)

Gets a hydrator for the given hydration mode.

newHydrator(int $hydrationMode)

Create a new instance for the given hydration mode.

getProxyFactory()

Gets the proxy factory used by the EntityManager to create entity proxies.

getFilters()

Gets the enabled filters.

bool
isFiltersStateClean()

Checks whether the state of the filter collection is clean.

bool
hasFilters()

Checks whether the Entity Manager has filters.

Cache|null
getCache()

Returns the cache API for managing the second level cache regions or NULL if the cache is not enabled.

Details

__construct(EntityManagerInterface $wrapped)

Parameters

EntityManagerInterface $wrapped

Connection getConnection()

Gets the database connection object used by the EntityManager.

Return Value

Connection

Expr getExpressionBuilder()

Gets an ExpressionBuilder used for object-oriented construction of query expressions.

Example:

$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)));

Return Value

Expr

IdentifierFlattener getIdentifierFlattener()

Gets an IdentifierFlattener used for converting Entities into an array of identifier values.

Return Value

IdentifierFlattener

void beginTransaction()

Starts a transaction on the underlying database connection.

Return Value

void

mixed transactional(callable $func)

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.

Parameters

callable $func The function to execute transactionally.

Return Value

mixed The value returned from the closure.

Exceptions

Throwable

void commit()

Commits a transaction on the underlying database connection.

Return Value

void

void rollback()

Performs a rollback on the underlying database connection.

Return Value

void

Query createQuery(string $dql = '')

Creates a new Query object.

Parameters

string $dql The DQL string.

Return Value

Query

NativeQuery createNativeQuery(string $sql, ResultSetMapping $rsm)

Creates a native SQL query.

Parameters

string $sql
ResultSetMapping $rsm The ResultSetMapping to use.

Return Value

NativeQuery

QueryBuilder createQueryBuilder()

Create a QueryBuilder instance

Return Value

QueryBuilder

object|GhostObjectInterface|null getReference(string $entityName, mixed $id)

Gets a reference to the entity identified by the given type and identifier without actually loading it, if the entity is not yet loaded.

Parameters

string $entityName The name of the entity type.
mixed $id The entity identifier.

Return Value

object|GhostObjectInterface|null The entity reference.

Exceptions

ORMException

object getPartialReference(string $entityName, mixed $identifier)

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.

Parameters

string $entityName The name of the entity type.
mixed $identifier The entity identifier.

Return Value

object The (partial) entity reference.

void close()

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 Value

void

void lock(object $entity, int $lockMode, int|null $lockVersion = null)

Acquire a lock on the given entity.

Parameters

object $entity
int $lockMode
int|null $lockVersion

Return Value

void

Exceptions

OptimisticLockException
PessimisticLockException

find($entityName, $id, $lockMode = null, $lockVersion = null)

{@inheritdoc}

Parameters

$entityName
$id
$lockMode
$lockVersion

flush()

{@inheritdoc}

EventManager getEventManager()

Gets the EventManager used by the EntityManager.

Return Value

EventManager

Configuration getConfiguration()

Gets the Configuration used by the EntityManager.

Return Value

Configuration

bool isOpen()

Check if the Entity manager is open or closed.

Return Value

bool

UnitOfWork getUnitOfWork()

Gets the UnitOfWork used by the EntityManager to coordinate operations.

Return Value

UnitOfWork

AbstractHydrator getHydrator(int $hydrationMode)

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.

Parameters

int $hydrationMode

Return Value

AbstractHydrator

AbstractHydrator newHydrator(int $hydrationMode)

Create a new instance for the given hydration mode.

Parameters

int $hydrationMode

Return Value

AbstractHydrator

Exceptions

ORMException

ProxyFactory getProxyFactory()

Gets the proxy factory used by the EntityManager to create entity proxies.

Return Value

ProxyFactory

FilterCollection getFilters()

Gets the enabled filters.

Return Value

FilterCollection The active filter collection.

bool isFiltersStateClean()

Checks whether the state of the filter collection is clean.

Return Value

bool True, if the filter collection is clean.

bool hasFilters()

Checks whether the Entity Manager has filters.

Return Value

bool True, if the EM has a filter collection.

Cache|null getCache()

Returns the cache API for managing the second level cache regions or NULL if the cache is not enabled.

Return Value

Cache|null