Backend implements BackendInterface, SingletonInterface

A persistence backend. This backend maps objects to the relational model of the storage backend.

It persists all added, removed and changed objects.

Internal

only to be used within Extbase, not part of TYPO3 Core API.

Table of Contents

Interfaces

BackendInterface
A persistence backend interface
SingletonInterface
"empty" interface for singletons (marker interface pattern)

Properties

$aggregateRootObjects  : ObjectStorage
$changedEntities  : ObjectStorage
$configurationManager  : ConfigurationManagerInterface
$dataMapFactory  : DataMapFactory
$deletedEntities  : ObjectStorage
$eventDispatcher  : EventDispatcherInterface
$persistenceManager  : PersistenceManagerInterface
$referenceIndex  : ReferenceIndex
$reflectionService  : ReflectionService
$session  : Session
$storageBackend  : BackendInterface
$visitedDuringPersistence  : ObjectStorage

Methods

__construct()  : mixed
Constructs the backend
commit()  : mixed
Commits the current persistence session.
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.
isNewObject()  : bool
Checks if the given object has ever been persisted.
setAggregateRootObjects()  : mixed
Sets the aggregate root objects
setChangedEntities()  : mixed
Sets the changed objects
setDeletedEntities()  : mixed
Sets the deleted objects
setPersistenceManager()  : void
Set a PersistenceManager instance.
addCommonDateFieldsToRow()  : void
Adjusts the common date fields of the given row to the current time
addCommonFieldsToRow()  : void
Adds common database fields to a row
attachObjectToParentObject()  : void
Updates the fields defining the relation between the object and the parent object.
attachObjectToParentObjectRelationHasMany()  : void
Updates fields defining the relation between the object and the parent object in relation has-many.
deleteAllRelationsFromRelationtable()  : bool
Delete all mm-relations of a parent from a relation table
deleteRelationFromRelationtable()  : bool
Delete an mm-relation from a relation table
detachObjectFromParentObject()  : void
Updates the fields defining the relation between the object and the parent object.
determineStoragePageIdForNewRecord()  : int
Determine the storage page ID for a given NEW record
getPlainValue()  : int|string|null
Returns a plain value, i.e. objects are flattened out if possible.
getRemovedChildObjects()  : array<string|int, mixed>
Returns the removed objects determined by a comparison of the clean property value with the actual property value.
getUidOfAlreadyPersistedValueObject()  : int|null
Tests, if the given Value Object already exists in the storage backend and if so, it returns the uid.
insertObject()  : void
Inserts an object in the storage backend
insertRelationInRelationtable()  : int
Inserts mm-relation into a relation table
persistObject()  : void
Persists the given object.
persistObjects()  : void
Traverse and persist all aggregate roots and their object graph.
persistObjectStorage()  : void
Persists an object storage. Objects of a 1:n or m:n relation are queued and processed with the parent object.
processDeletedObjects()  : void
Iterate over deleted aggregate root objects and process them
propertyValueIsLazyLoaded()  : bool
Checks, if the property value is lazy loaded and was not initialized
removeEntity()  : void
Deletes an object
removeRelatedObjects()  : void
Remove related objects
updateObject()  : bool
Updates a given object in the storage
updateRelationInRelationTable()  : bool
Updates mm-relation in a relation table
updateRelationOfObjectToParentObject()  : void
Updates the fields defining the relation between the object and the parent object.

Properties

$eventDispatcher read-only

protected EventDispatcherInterface $eventDispatcher

Methods

__construct()

Constructs the backend

public __construct(ConfigurationManagerInterface $configurationManager, Session $session, ReflectionService $reflectionService, BackendInterface $storageBackend, DataMapFactory $dataMapFactory, EventDispatcherInterface $eventDispatcher) : mixed
Parameters
$configurationManager : ConfigurationManagerInterface
$session : Session
$reflectionService : ReflectionService
$storageBackend : BackendInterface
$dataMapFactory : DataMapFactory
$eventDispatcher : EventDispatcherInterface
Tags
todo

Refactor unit tests, so all promoted properties can be readonly

commit()

Commits the current persistence session.

public commit() : mixed

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
Parameters
$object : object
Return values
string|null

The identifier for the object if it is known, or NULL

getObjectByIdentifier()

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

public getObjectByIdentifier(string $identifier, string $className) : object|null
Parameters
$identifier : string
$className : string
Return values
object|null

The object for the identifier if it is known, or 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>>

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 repository

addCommonDateFieldsToRow()

Adjusts the common date fields of the given row to the current time

protected addCommonDateFieldsToRow(DomainObjectInterface $object, array<string|int, mixed> &$row) : void
Parameters
$object : DomainObjectInterface
$row : array<string|int, mixed>

attachObjectToParentObjectRelationHasMany()

Updates fields defining the relation between the object and the parent object in relation has-many.

protected attachObjectToParentObjectRelationHasMany(DomainObjectInterface $object, DomainObjectInterface $parentObject, string $parentPropertyName[, int $sortingPosition = 0 ]) : void
Parameters
$object : DomainObjectInterface
$parentObject : DomainObjectInterface
$parentPropertyName : string
$sortingPosition : int = 0
Tags
throws
IllegalRelationTypeException

deleteAllRelationsFromRelationtable()

Delete all mm-relations of a parent from a relation table

protected deleteAllRelationsFromRelationtable(DomainObjectInterface $parentObject, string $parentPropertyName) : bool
Parameters
$parentObject : DomainObjectInterface
$parentPropertyName : string
Return values
bool

TRUE if delete was successfully

determineStoragePageIdForNewRecord()

Determine the storage page ID for a given NEW record

protected determineStoragePageIdForNewRecord([DomainObjectInterface|null $object = null ]) : int

This does the following:

  • If the domain object has an accessible property 'pid' (i.e. through a getPid() method), that is used to store the record.
  • If there is a TypoScript configuration "classes.CLASSNAME.newRecordStoragePid", that is used to store new records.
  • If there is no such TypoScript configuration, it uses the first value of The "storagePid" taken for reading records.
Parameters
$object : DomainObjectInterface|null = null
Return values
int

the storage Page ID where the object should be stored

getPlainValue()

Returns a plain value, i.e. objects are flattened out if possible.

protected getPlainValue(mixed $input[, ColumnMap|null $columnMap = null ][, Property|null $property = null ]) : int|string|null

Checks explicitly for null values as DataMapper's getPlainValue would convert this to 'NULL'. For null values, the expected DB null value will be considered.

Parameters
$input : mixed

The value that will be converted

$columnMap : ColumnMap|null = null

Optional column map for retrieving the date storage format

$property : Property|null = null

The current property

Return values
int|string|null

getRemovedChildObjects()

Returns the removed objects determined by a comparison of the clean property value with the actual property value.

protected getRemovedChildObjects(DomainObjectInterface $object, string $propertyName) : array<string|int, mixed>
Parameters
$object : DomainObjectInterface
$propertyName : string
Return values
array<string|int, mixed>

getUidOfAlreadyPersistedValueObject()

Tests, if the given Value Object already exists in the storage backend and if so, it returns the uid.

protected getUidOfAlreadyPersistedValueObject(AbstractValueObject $object) : int|null
Parameters
$object : AbstractValueObject
Return values
int|null

The matching uid if an object was found, else null

persistObjects()

Traverse and persist all aggregate roots and their object graph.

protected persistObjects() : void

persistObjectStorage()

Persists an object storage. Objects of a 1:n or m:n relation are queued and processed with the parent object.

protected persistObjectStorage(ObjectStorage $objectStorage, DomainObjectInterface $parentObject, string $propertyName, array<string|int, mixed> &$row) : void

A 1:1 relation gets persisted immediately. Objects which were removed from the property were detached from the parent object. They will not be deleted by default. You have to annotate the property with '@TYPO3\CMS\Extbase\Annotation\ORM\Cascade("remove")' if you want them to be deleted as well.

Parameters
$objectStorage : ObjectStorage

The object storage to be persisted.

$parentObject : DomainObjectInterface

The parent object. One of the properties holds the object storage.

$propertyName : string

The name of the property holding the object storage.

$row : array<string|int, mixed>

The row array of the parent object to be persisted. It's passed by reference and gets filled with either a comma separated list of uids (csv) or the number of contained objects.

processDeletedObjects()

Iterate over deleted aggregate root objects and process them

protected processDeletedObjects() : void

propertyValueIsLazyLoaded()

Checks, if the property value is lazy loaded and was not initialized

protected propertyValueIsLazyLoaded(mixed $propertyValue) : bool
Parameters
$propertyValue : mixed
Return values
bool

        
On this page

Search results