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<string|int, mixed>
- $persistenceSession : Session
- $queryFactory : QueryFactoryInterface
- $removedObjects : ObjectStorage
Methods
- __construct() : mixed
- Create new instance
- add() : mixed
- Adds an object to the persistence.
- clearState() : mixed
- Clears the in-memory state of the persistence.
- createQueryForType() : QueryInterface
- Return a query object for the given type.
- getIdentifierByObject() : mixed
- Returns the (internal) identifier for the object, if it is known to the backend. Otherwise NULL is returned.
- getObjectByIdentifier() : object
- 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<string|int, mixed>
- Returns the object data matching the $query.
- initializeObject() : mixed
- Initializes the persistence manager, called by Extbase.
- isNewObject() : bool
- Checks if the given object has ever been persisted.
- persistAll() : mixed
- Commits new objects and changes to objects in the current persistence session into the backend.
- registerNewObject() : mixed
- Registers an object which has been created or cloned during this request.
- registerRepositoryClassName() : mixed
- Registers a repository
- remove() : mixed
- Removes an object to the persistence.
- tearDown() : void
- Tear down the persistence
- update() : mixed
- Update an object in the persistence.
Properties
$addedObjects
protected
ObjectStorage
$addedObjects
$backend
protected
BackendInterface
$backend
$changedObjects
protected
ObjectStorage
$changedObjects
$newObjects
protected
array<string|int, mixed>
$newObjects
= []
$persistenceSession
protected
Session
$persistenceSession
$queryFactory
protected
QueryFactoryInterface
$queryFactory
$removedObjects
protected
ObjectStorage
$removedObjects
Methods
__construct()
Create new instance
public
__construct(QueryFactoryInterface $queryFactory, BackendInterface $backend, Session $persistenceSession) : mixed
Parameters
- $queryFactory : QueryFactoryInterface
- $backend : BackendInterface
- $persistenceSession : Session
only to be used within Extbase, not part of TYPO3 Core API.
add()
Adds an object to the persistence.
public
add(object $object) : mixed
Parameters
- $object : object
-
The object to add
clearState()
Clears the in-memory state of the persistence.
public
clearState() : mixed
Managed instances become detached, any fetches will return data directly from the persistence "backend".
only to be used within Extbase, not part of TYPO3 Core API.
Tags
createQueryForType()
Return a query object for the given type.
public
createQueryForType(string $type) : QueryInterface
Parameters
- $type : string
only to be used within Extbase, not part of TYPO3 Core API.
Return values
QueryInterfacegetIdentifierByObject()
Returns the (internal) identifier for the object, if it is known to the backend. Otherwise NULL is returned.
public
getIdentifierByObject(object $object) : mixed
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
mixed —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(mixed $identifier[, string $objectType = null ][, bool $useLazyLoading = false ]) : object
Parameters
- $identifier : mixed
- $objectType : string = null
- $useLazyLoading : bool = false
-
Set to TRUE if you want to use lazy loading for this object
Return values
object —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
intgetObjectDataByQuery()
Returns the object data matching the $query.
public
getObjectDataByQuery(QueryInterface $query) : array<string|int, mixed>
Parameters
- $query : QueryInterface
Return values
array<string|int, mixed>initializeObject()
Initializes the persistence manager, called by Extbase.
public
initializeObject() : mixed
only to be used within Extbase, not part of TYPO3 Core API.
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() : mixed
registerNewObject()
Registers an object which has been created or cloned during this request.
public
registerNewObject(object $object) : mixed
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
only to be used within Extbase, not part of TYPO3 Core API.
registerRepositoryClassName()
Registers a repository
public
registerRepositoryClassName(string $className) : mixed
Parameters
- $className : string
-
The class name of the repository to be registered
only to be used within Extbase, not part of TYPO3 Core API.
remove()
Removes an object to the persistence.
public
remove(object $object) : mixed
Parameters
- $object : object
-
The object to remove
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.
only to be used within Extbase, not part of TYPO3 Core API.
update()
Update an object in the persistence.
public
update(object $object) : mixed
Parameters
- $object : object
-
The modified object