mediatekformation

ObjectManager

Contract for a Doctrine persistence layer ObjectManager class to implement.

Table of Contents

clear()  : void
Clears the ObjectManager. All objects that are currently managed by this ObjectManager become detached.
contains()  : bool
Checks if the object is part of the current UnitOfWork and therefore managed.
detach()  : void
Detaches an object from the ObjectManager, causing a managed object to become detached. Unflushed changes made to the object if any (including removal of the object), will not be synchronized to the database.
find()  : object|null
Finds an object by its identifier.
flush()  : void
Flushes all changes to objects that have been queued up to now to the database.
getClassMetadata()  : ClassMetadata
Returns the ClassMetadata descriptor for a class.
getMetadataFactory()  : ClassMetadataFactory
Gets the metadata factory used to gather the metadata of classes.
getRepository()  : ObjectRepository
Gets the repository for a class.
initializeObject()  : void
Helper method to initialize a lazy loading proxy or persistent collection.
merge()  : object
Merges the state of a detached object into the persistence context of this ObjectManager and returns the managed copy of the object.
persist()  : void
Tells the ObjectManager to make an instance managed and persistent.
refresh()  : void
Refreshes the persistent state of an object from the database, overriding any local changes that have not yet been persisted.
remove()  : void
Removes an object instance.

Methods

clear()

Clears the ObjectManager. All objects that are currently managed by this ObjectManager become detached.

public clear([string|null $objectName = null ]) : void
Parameters
$objectName : string|null = null

if given, only objects of this type will get detached.

Return values
void

contains()

Checks if the object is part of the current UnitOfWork and therefore managed.

public contains(object $object) : bool
Parameters
$object : object
Return values
bool

detach()

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

public detach(object $object) : void

Objects which previously referenced the detached object will continue to reference it.

Parameters
$object : object

The object to detach.

Return values
void

find()

Finds an object by its identifier.

public find(string $className, mixed $id) : object|null

This is just a convenient shortcut for getRepository($className)->find($id).

Parameters
$className : string

The class name of the object to find.

$id : mixed

The identity of the object to find.

Tags
psalm-param

class-string<T> $className

psalm-return

T|null

template

T of object

Return values
object|null

The found object.

flush()

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

public flush() : void

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

Return values
void

getClassMetadata()

Returns the ClassMetadata descriptor for a class.

public getClassMetadata(string $className) : ClassMetadata

The class name must be the fully-qualified class name without a leading backslash (as it is returned by get_class($obj)).

Parameters
$className : string
Tags
psalm-param

class-string<T> $className

psalm-return

ClassMetadata<T>

template

T of object

Return values
ClassMetadata

getMetadataFactory()

Gets the metadata factory used to gather the metadata of classes.

public getMetadataFactory() : ClassMetadataFactory
Tags
psalm-return

ClassMetadataFactory<ClassMetadata>

Return values
ClassMetadataFactory

getRepository()

Gets the repository for a class.

public getRepository(string $className) : ObjectRepository
Parameters
$className : string
Tags
psalm-param

class-string<T> $className

psalm-return

ObjectRepository<T>

template

T

Return values
ObjectRepository

initializeObject()

Helper method to initialize a lazy loading proxy or persistent collection.

public initializeObject(object $obj) : void

This method is a no-op for other objects.

Parameters
$obj : object
Return values
void

merge()

Merges the state of a detached object into the persistence context of this ObjectManager and returns the managed copy of the object.

public merge(object $object) : object

The object passed to merge will not become associated/managed with this ObjectManager.

Parameters
$object : object
Tags
deprecated

Merge operation is deprecated and will be removed in Persistence 2.0. Merging should be part of the business domain of an application rather than a generic operation of ObjectManager.

Return values
object

persist()

Tells the ObjectManager to make an instance managed and persistent.

public persist(object $object) : void

The object will be entered into the database as a result of the flush operation.

NOTE: The persist operation always considers objects that are not yet known to this ObjectManager as NEW. Do not pass detached objects to the persist operation.

Parameters
$object : object

The instance to make managed and persistent.

Return values
void

refresh()

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

public refresh(object $object) : void
Parameters
$object : object

The object to refresh.

Return values
void

remove()

Removes an object instance.

public remove(object $object) : void

A removed object will be removed from the database as a result of the flush operation.

Parameters
$object : object

The object instance to remove.

Return values
void

Search results