mediatekformation

EntityManager_9a5be93 extends EntityManager
in package
implements VirtualProxyInterface

The EntityManager is the central access point to ORM functionality.

It is a facade to all different ORM subsystems such as UnitOfWork, Query Language and Repository API. Instantiation is done through the static create() method. The quickest way to obtain a fully configured EntityManager is:

use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;

$paths = array('/path/to/entity/mapping/files');

$config = Setup::createAnnotationMetadataConfiguration($paths);
$dbParams = array('driver' => 'pdo_sqlite', 'memory' => true);
$entityManager = EntityManager::create($dbParams, $config);

For more information see

You should never attempt to inherit from the EntityManager: Inheritance is not a valid extension point for the EntityManager. Instead you should take a look at the EntityManagerDecorator and wrap your entity manager in a decorator.

Interfaces, Classes, Traits and Enums

VirtualProxyInterface
Virtual Proxy - a lazy initializing object wrapping around the proxied subject

Table of Contents

$cache  : Cache
$closed  : bool
Whether the EntityManager is closed or not.
$config  : Configuration
The used Configuration.
$conn  : Connection
The database connection used by the EntityManager.
$eventManager  : EventManager
The event manager that is the central point of the event system.
$expressionBuilder  : Expr
The expression builder instance used to generate query expressions.
$filterCollection  : FilterCollection
Collection of query filters.
$initializer7bb73  : Closure|null
$metadataFactory  : ClassMetadataFactory
The metadata factory, used to retrieve the ORM metadata of entity classes.
$proxyFactory  : ProxyFactory
The proxy factory used to create dynamic proxies.
$publicProperties1b3ee  : array<string|int, bool>
$repositoryFactory  : RepositoryFactory
The repository factory used to create dynamic repositories.
$unitOfWork  : UnitOfWork
The UnitOfWork used to coordinate object-level transactions.
$valueHolderb9586  : EntityManager|null
__clone()  : mixed
__get()  : mixed
__isset()  : mixed
__set()  : mixed
__sleep()  : mixed
__unset()  : mixed
__wakeup()  : mixed
beginTransaction()  : void
Starts a transaction on the underlying database connection.
clear()  : void
Clears the EntityManager. All entities that are currently managed by this EntityManager become detached.
close()  : void
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.
commit()  : void
Commits a transaction on the underlying database connection.
contains()  : bool
Determines whether an entity instance is managed in this EntityManager.
copy()  : object
Creates a copy of the given entity. Can create a shallow or a deep copy.
create()  : EntityManager
Factory method to create EntityManager instances.
createNamedNativeQuery()  : NativeQuery
Creates a NativeQuery from a named native query.
createNamedQuery()  : Query
Creates a Query from a named query.
createNativeQuery()  : NativeQuery
Creates a native SQL query.
createQuery()  : Query
Creates a new Query object.
createQueryBuilder()  : QueryBuilder
Create a QueryBuilder instance
detach()  : void
Detaches an entity from the EntityManager, causing a managed entity to become detached. Unflushed changes made to the entity if any (including removal of the entity), will not be synchronized to the database.
find()  : object|null
Finds an Entity by its identifier.
flush()  : void
Flushes all changes to objects that have been queued up to now to the database.
getCache()  : Cache|null
Returns the cache API for managing the second level cache regions or NULL if the cache is not enabled.
getClassMetadata()  : ClassMetadata
Returns the ORM metadata descriptor for a class.
getConfiguration()  : Configuration
Gets the Configuration used by the EntityManager.
getConnection()  : Connection
Gets the database connection object used by the EntityManager.
getEventManager()  : EventManager
Gets the EventManager used by the EntityManager.
getExpressionBuilder()  : Expr
Gets an ExpressionBuilder used for object-oriented construction of query expressions.
getFilters()  : FilterCollection
Gets the enabled filters.
getHydrator()  : AbstractHydrator
Gets a hydrator for the given hydration mode.
getMetadataFactory()  : ClassMetadataFactory
Gets the metadata factory used to gather the metadata of classes.
getPartialReference()  : object|null
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.
getProxyFactory()  : ProxyFactory
Gets the proxy factory used by the EntityManager to create entity proxies.
getProxyInitializer()  : Closure|null
getReference()  : object|null
Gets a reference to the entity identified by the given type and identifier without actually loading it, if the entity is not yet loaded.
getRepository()  : ObjectRepository|EntityRepository
Gets the repository for an entity class.
getUnitOfWork()  : UnitOfWork
Gets the UnitOfWork used by the EntityManager to coordinate operations.
getWrappedValueHolderValue()  : mixed
hasFilters()  : bool
Checks whether the Entity Manager has filters.
initializeObject()  : mixed
{@inheritDoc}
initializeProxy()  : bool
isFiltersStateClean()  : bool
Checks whether the state of the filter collection is clean.
isOpen()  : bool
Check if the Entity manager is open or closed.
isProxyInitialized()  : bool
lock()  : void
Acquire a lock on the given entity.
merge()  : object
Merges the state of a detached entity into the persistence context of this EntityManager and returns the managed copy of the entity.
newHydrator()  : AbstractHydrator
Create a new instance for the given hydration mode.
persist()  : void
Tells the EntityManager to make an instance managed and persistent.
refresh()  : void
Refreshes the persistent state of an entity from the database, overriding any local changes that have not yet been persisted.
remove()  : void
Removes an entity instance.
rollback()  : void
Performs a rollback on the underlying database connection.
setProxyInitializer()  : void
staticProxyConstructor()  : mixed
Constructor for lazy initialization
transactional()  : mixed
Executes a function in a transaction.
wrapInTransaction()  : mixed
{@inheritDoc}
__construct()  : mixed
Creates a new EntityManager that operates on the given database connection and uses the given Configuration and EventManager implementations.
createConnection()  : Connection
Factory method to create Connection instances.
checkLockRequirements()  : void
configureLegacyMetadataCache()  : void
configureMetadataCache()  : void
errorIfClosed()  : void
Throws an exception if the EntityManager is closed or currently not active.

Properties

$closed

Whether the EntityManager is closed or not.

private bool $closed = false

$conn

The database connection used by the EntityManager.

private Connection $conn

$expressionBuilder

The expression builder instance used to generate query expressions.

private Expr $expressionBuilder

$initializer7bb73

private Closure|null $initializer7bb73 = null

initializer responsible for generating the wrapped object

$publicProperties1b3ee

private static array<string|int, bool> $publicProperties1b3ee = []

map of public properties of the parent class

Methods

__get()

public __get(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed —

__isset()

public __isset(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed —

__set()

public __set(mixed $name, mixed $value) : mixed
Parameters
$name : mixed
$value : mixed
Return values
mixed —

__unset()

public __unset(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed —

__wakeup()

public __wakeup() : mixed
Return values
mixed —

beginTransaction()

Starts a transaction on the underlying database connection.

public beginTransaction() : void
Return values
void —

clear()

Clears the EntityManager. All entities that are currently managed by this EntityManager become detached.

public clear([mixed $entityName = null ]) : void
Parameters
$entityName : mixed = null

if given, only entities of this type will get detached

Return values
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.

public close() : void
Return values
void —

commit()

Commits a transaction on the underlying database connection.

public commit() : void
Return values
void —

contains()

Determines whether an entity instance is managed in this EntityManager.

public contains(mixed $entity) : bool
Parameters
$entity : mixed
Return values
bool —

TRUE if this EntityManager currently manages the given entity, FALSE otherwise.

copy()

Creates a copy of the given entity. Can create a shallow or a deep copy.

public copy(mixed $entity[, mixed $deep = false ]) : object
Parameters
$entity : mixed

The entity to copy.

$deep : mixed = false

FALSE for a shallow copy, TRUE for a deep copy.

Return values
object —

The new entity.

create()

Factory method to create EntityManager instances.

public static create(array<string|int, mixed>|Connection $connection, Configuration $config[, EventManager|null $eventManager = null ]) : EntityManager
Parameters
$connection : array<string|int, mixed>|Connection

An array with the connection parameters or an existing Connection instance.

$config : Configuration

The Configuration instance to use.

$eventManager : EventManager|null = null

The EventManager instance to use.

Tags
psalm-param

array<string, mixed>|Connection $connection

throws
InvalidArgumentException
throws
ORMException
Return values
EntityManager —

The created EntityManager.

createNamedNativeQuery()

Creates a NativeQuery from a named native query.

public createNamedNativeQuery(mixed $name) : NativeQuery
Parameters
$name : mixed
Return values
NativeQuery —

createNamedQuery()

Creates a Query from a named query.

public createNamedQuery(mixed $name) : Query
Parameters
$name : mixed
Return values
Query —

createQuery()

Creates a new Query object.

public createQuery([mixed $dql = '' ]) : Query
Parameters
$dql : mixed = ''

The DQL string.

Return values
Query —

detach()

Detaches an entity from the EntityManager, causing a managed entity to become detached. Unflushed changes made to the entity if any (including removal of the entity), will not be synchronized to the database.

public detach(mixed $entity) : void

Entities which previously referenced the detached entity will continue to reference it.

Parameters
$entity : mixed

The entity to detach.

Return values
void —

find()

Finds an Entity by its identifier.

public find(mixed $className, mixed $id[, mixed $lockMode = null ][, mixed $lockVersion = null ]) : object|null
Parameters
$className : mixed

The class name of the entity to find.

$id : mixed

The identity of the entity to find.

$lockMode : mixed = null

One of the \Doctrine\DBAL\LockMode::* constants or NULL if no specific lock mode should be used during the search.

$lockVersion : mixed = null

The version of the entity to find when using optimistic locking.

Return values
object|null —

The entity instance or NULL if the entity can not be found.

flush()

Flushes all changes to objects that have been queued up to now to the database.

public flush([mixed $entity = null ]) : void

This effectively synchronizes the in-memory state of managed objects with the database.

If an entity is explicitly passed to this method only this entity and the cascade-persist semantics + scheduled inserts/removals are synchronized.

Parameters
$entity : mixed = null
Return values
void —

getCache()

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

public getCache() : Cache|null
Return values
Cache|null —

getClassMetadata()

Returns the ORM metadata descriptor for a class.

public getClassMetadata(mixed $className) : ClassMetadata

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

Internal note: Performance-sensitive method.

Parameters
$className : mixed
Return values
ClassMetadata —

getConnection()

Gets the database connection object used by the EntityManager.

public getConnection() : Connection
Return values
Connection —

getExpressionBuilder()

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

public getExpressionBuilder() : Expr
Return values
Expr —

getPartialReference()

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.

public getPartialReference(mixed $entityName, mixed $identifier) : object|null
Parameters
$entityName : mixed

The name of the entity type.

$identifier : mixed

The entity identifier.

Return values
object|null —

The (partial) entity reference

getProxyInitializer()

public getProxyInitializer() : Closure|null
Return values
Closure|null —

getReference()

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

public getReference(mixed $entityName, mixed $id) : object|null
Parameters
$entityName : mixed

The name of the entity type.

$id : mixed

The entity identifier.

Return values
object|null —

The entity reference.

getWrappedValueHolderValue()

public getWrappedValueHolderValue() : mixed
Return values
mixed —

hasFilters()

Checks whether the Entity Manager has filters.

public hasFilters() : bool
Return values
bool —

True, if the EM has a filter collection.

initializeObject()

{@inheritDoc}

public initializeObject(mixed $obj) : mixed
Parameters
$obj : mixed
Return values
mixed —

initializeProxy()

public initializeProxy() : bool
Return values
bool —

isFiltersStateClean()

Checks whether the state of the filter collection is clean.

public isFiltersStateClean() : bool
Return values
bool —

True, if the filter collection is clean.

isOpen()

Check if the Entity manager is open or closed.

public isOpen() : bool
Return values
bool —

isProxyInitialized()

public isProxyInitialized() : bool
Return values
bool —

lock()

Acquire a lock on the given entity.

public lock(mixed $entity, mixed $lockMode[, mixed $lockVersion = null ]) : void
Parameters
$entity : mixed
$lockMode : mixed
$lockVersion : mixed = null
Return values
void —

merge()

Merges the state of a detached entity into the persistence context of this EntityManager and returns the managed copy of the entity.

public merge(mixed $entity) : object

The entity passed to merge will not become associated/managed with this EntityManager.

Parameters
$entity : mixed

The detached entity to merge into the persistence context.

Return values
object —

The managed copy of the entity.

persist()

Tells the EntityManager to make an instance managed and persistent.

public persist(mixed $entity) : void

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.

Parameters
$entity : mixed

The instance to make managed and persistent.

Return values
void —

refresh()

Refreshes the persistent state of an entity from the database, overriding any local changes that have not yet been persisted.

public refresh(mixed $entity) : void
Parameters
$entity : mixed

The entity to refresh.

Return values
void —

remove()

Removes an entity instance.

public remove(mixed $entity) : void

A removed entity will be removed from the database at or before transaction commit or as a result of the flush operation.

Parameters
$entity : mixed

The entity instance to remove.

Return values
void —

rollback()

Performs a rollback on the underlying database connection.

public rollback() : void
Return values
void —

setProxyInitializer()

public setProxyInitializer([Closure $initializer = null ]) : void
Parameters
$initializer : Closure = null
Return values
void —

staticProxyConstructor()

Constructor for lazy initialization

public static staticProxyConstructor(Closure|null $initializer) : mixed
Parameters
$initializer : Closure|null
Return values
mixed —

transactional()

Executes a function in a transaction.

public transactional(mixed $func) : mixed
Parameters
$func : mixed

The function to execute transactionally.

Return values
mixed —

The non-empty value returned from the closure or true instead.

wrapInTransaction()

{@inheritDoc}

public wrapInTransaction(callable $func) : mixed
Parameters
$func : callable
Return values
mixed —

__construct()

Creates a new EntityManager that operates on the given database connection and uses the given Configuration and EventManager implementations.

protected __construct(Connection $conn, Configuration $config, EventManager $eventManager) : mixed
Parameters
$conn : Connection
$config : Configuration
$eventManager : EventManager
Return values
mixed —

createConnection()

Factory method to create Connection instances.

protected static createConnection(array<string|int, mixed>|Connection $connection, Configuration $config[, EventManager|null $eventManager = null ]) : Connection
Parameters
$connection : array<string|int, mixed>|Connection

An array with the connection parameters or an existing Connection instance.

$config : Configuration

The Configuration instance to use.

$eventManager : EventManager|null = null

The EventManager instance to use.

Tags
psalm-param

array<string, mixed>|Connection $connection

throws
InvalidArgumentException
throws
ORMException
Return values
Connection —

configureLegacyMetadataCache()

private configureLegacyMetadataCache() : void
Return values
void —

configureMetadataCache()

private configureMetadataCache() : void
Return values
void —

errorIfClosed()

Throws an exception if the EntityManager is closed or currently not active.

private errorIfClosed() : void
Tags
throws
EntityManagerClosed

If the EntityManager is closed.

Return values
void —

Search results