Documentation

ObjectManager

Contract for a Doctrine persistence layer ObjectManager class to implement.

Table of Contents

Methods

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()  : mixed
Returns the ClassMetadata descriptor for a class.
getMetadataFactory()  : mixed
Gets the metadata factory used to gather the metadata of classes.
getRepository()  : mixed
Gets the repository for a class.
initializeObject()  : void
Helper method to initialize a lazy loading proxy or persistent collection.
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() : 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.

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.

getClassMetadata()

Returns the ClassMetadata descriptor for a class.

public getClassMetadata(string $className) : mixed

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

getMetadataFactory()

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

public getMetadataFactory() : mixed
Tags
psalm-return

ClassMetadataFactory<ClassMetadata>

getRepository()

Gets the repository for a class.

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

class-string<T> $className

psalm-return

ObjectRepository<T>

template

T of object

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

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.

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.

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.


        
On this page

Search results