PersistenceManager

class \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager

Implements
PersistenceManagerInterface, SingletonInterface

The Extbase Persistence Manager

Table of Contents

Interfaces

PersistenceManagerInterface
The Extbase Persistence Manager interface
SingletonInterface
"empty" interface for singletons (marker interface pattern)

Properties

$addedObjects  : ObjectStorage
$backend  : BackendInterface
$changedObjects  : ObjectStorage
$newObjects  : array
$persistenceSession  : Session
$queryFactory  : QueryFactoryInterface
$removedObjects  : ObjectStorage

Methods

__construct()  : mixed
add()  : void
Adds an object to the persistence.
clearState()  : void
Clears the in-memory state of the persistence.
createQueryForType()  : QueryInterface<string|int, T>
Return a query object for the given type.
getIdentifierByObject()  : string|null
Returns the (internal) identifier for the object, if it is known to the backend. Otherwise, `null` is returned.
getObjectByIdentifier()  : object|null
Returns the object with the (internal) identifier if it is known to the backend. Otherwise, `null` is returned.
getObjectCountByQuery()  : int
Returns the number of records matching the query.
getObjectDataByQuery()  : array<int, array<string, mixed>>
Returns the object data matching the `$query`.
initializeObject()  : void
Initializes the persistence manager, called by Extbase.
isNewObject()  : bool
Checks if the given object has ever been persisted.
persistAll()  : void
Commits new objects and changes to objects in the current persistence session into the backend.
registerNewObject()  : void
Registers an object which has been created or cloned during this request.
registerRepositoryClassName()  : void
Registers a repository
remove()  : void
Removes an object to the persistence.
tearDown()  : void
Tear down the persistence
update()  : void
Update an object in the persistence.

Properties

$newObjects

protected array $newObjects = []

Methods

add()

Adds an object to the persistence.

public add(object $object) : void

Parameters

$object : object

clearState()

Clears the in-memory state of the persistence.

public clearState() : void

Managed instances become detached, any fetches will return data directly from the persistence "backend".

createQueryForType()

Return a query object for the given type.

public createQueryForType(class-string $type) : QueryInterface<string|int, T>

Parameters

$type : class-string

Tags

template

Return values

QueryInterface<string|int, T>

getIdentifierByObject()

Returns the (internal) identifier for the object, if it is known to the backend. Otherwise, `null` is returned.

public getIdentifierByObject(object $object) : string|null

Note: this returns an identifier even if the object has not been persisted in case of AOP-managed entities. Use isNewObject() if you need to distinguish those cases.

Parameters

$object : object

Return values

string|null

getObjectByIdentifier()

Returns the object with the (internal) identifier if it is known to the backend. Otherwise, `null` is returned.

public getObjectByIdentifier(string|int $identifier[, string|null $objectType = null ][, bool $useLazyLoading = false ]) : object|null

Parameters

$identifier : string|int
$objectType : string|null = null
$useLazyLoading : bool = false

Return values

object|null

getObjectCountByQuery()

Returns the number of records matching the query.

public getObjectCountByQuery(QueryInterface $query) : int

Parameters

$query : QueryInterface

Return values

int

getObjectDataByQuery()

Returns the object data matching the `$query`.

public getObjectDataByQuery(QueryInterface $query) : array<int, array<string, mixed>>

Parameters

$query : QueryInterface

Return values

array<int, array<string, mixed>>

initializeObject()

Initializes the persistence manager, called by Extbase.

public initializeObject() : void

isNewObject()

Checks if the given object has ever been persisted.

public isNewObject(object $object) : bool

Parameters

$object : object

The object to check

Return values

bool —

TRUE if the object is new, FALSE if the object exists in the persistence session

persistAll()

Commits new objects and changes to objects in the current persistence session into the backend.

public persistAll() : void

registerNewObject()

Registers an object which has been created or cloned during this request.

public registerNewObject(object $object) : void

A "new" object does not necessarily have to be known by any repository or be persisted in the end.

Objects registered with this method must be known to the getObjectByIdentifier() method.

Parameters

$object : object

The new object to register

registerRepositoryClassName()

Registers a repository

public registerRepositoryClassName(class-string $className) : void

Parameters

$className : class-string

The class name of the repository to be registered

remove()

Removes an object to the persistence.

public remove(object $object) : void

Parameters

$object : object

tearDown()

Tear down the persistence

public tearDown() : void

This method is called in functional tests to reset the storage between tests. The implementation is optional and depends on the underlying persistence backend.

On this page