‪TYPO3CMS  ‪main
TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager Class Reference
Inheritance diagram for TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager:
TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface TYPO3\CMS\Core\SingletonInterface

Public Member Functions

 __construct (QueryFactoryInterface $queryFactory, BackendInterface $backend, Session $persistenceSession)
 
 registerRepositoryClassName (string $className)
 
 getObjectCountByQuery (QueryInterface $query)
 
 getObjectDataByQuery (QueryInterface $query)
 
string null getIdentifierByObject (object $object)
 
object null getObjectByIdentifier (string|int $identifier, ?string $objectType=null, bool $useLazyLoading=false)
 
 persistAll ()
 
QueryInterface< T > createQueryForType (string $type)
 
 add (object $object)
 
 remove (object $object)
 
 update (object $object)
 
 initializeObject ()
 
 clearState ()
 
bool isNewObject (object $object)
 
 registerNewObject (object $object)
 
 tearDown ()
 

Protected Attributes

array $newObjects = []
 
ObjectStorage $changedObjects
 
ObjectStorage $addedObjects
 
ObjectStorage $removedObjects
 
QueryFactoryInterface $queryFactory
 
BackendInterface $backend
 
Session $persistenceSession
 

Detailed Description

The Extbase Persistence Manager

Definition at line 29 of file PersistenceManager.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::__construct ( QueryFactoryInterface  $queryFactory,
BackendInterface  $backend,
Session  $persistenceSession 
)

Member Function Documentation

◆ add()

TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::add ( object  $object)

Adds an object to the persistence.

Parameters
object$object‪The object to add

Implements TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface.

Definition at line 154 of file PersistenceManager.php.

◆ clearState()

TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::clearState ( )

Clears the in-memory state of the persistence.

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

Exceptions

Implements TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface.

Definition at line 206 of file PersistenceManager.php.

◆ createQueryForType()

QueryInterface<T> TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::createQueryForType ( string  $type)

Return a query object for the given type.

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

@template T of object

Parameters
class-string<T>‪$type
Returns
‪QueryInterface<T>

Implements TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface.

Definition at line 144 of file PersistenceManager.php.

◆ getIdentifierByObject()

string null TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::getIdentifierByObject ( object  $object)

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

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.

Returns
‪string|null The identifier for the object if it is known, or NULL

Implements TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface.

Definition at line 92 of file PersistenceManager.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager\registerNewObject().

◆ getObjectByIdentifier()

object null TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::getObjectByIdentifier ( string|int  $identifier,
?string  $objectType = null,
bool  $useLazyLoading = false 
)

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

Parameters
bool$useLazyLoading‪Set to TRUE if you want to use lazy loading for this object
Returns
‪object|null The object for the identifier if it is known, or NULL

Implements TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface.

Definition at line 104 of file PersistenceManager.php.

References TYPO3\CMS\Webhooks\Message\$identifier.

◆ getObjectCountByQuery()

TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::getObjectCountByQuery ( QueryInterface  $query)

Returns the number of records matching the query.

Implements TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface.

Definition at line 69 of file PersistenceManager.php.

◆ getObjectDataByQuery()

TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::getObjectDataByQuery ( QueryInterface  $query)

Returns the object data matching the $query.

Implements TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface.

Definition at line 77 of file PersistenceManager.php.

◆ initializeObject()

TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::initializeObject ( )

Initializes the persistence manager, called by Extbase.

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

Definition at line 192 of file PersistenceManager.php.

◆ isNewObject()

bool TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::isNewObject ( object  $object)

Checks if the given object has ever been persisted.

Parameters
object$object‪The object to check
Returns
‪bool TRUE if the object is new, FALSE if the object exists in the persistence session

Implements TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface.

Definition at line 221 of file PersistenceManager.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager\update().

◆ persistAll()

TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::persistAll ( )

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

Implements TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface.

Definition at line 119 of file PersistenceManager.php.

◆ registerNewObject()

TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::registerNewObject ( object  $object)

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

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.

Definition at line 239 of file PersistenceManager.php.

References TYPO3\CMS\Webhooks\Message\$identifier, and TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager\getIdentifierByObject().

◆ registerRepositoryClassName()

TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::registerRepositoryClassName ( string  $className)

Registers a repository

Parameters
string$className‪The class name of the repository to be registered

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

Implements TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface.

Definition at line 64 of file PersistenceManager.php.

◆ remove()

TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::remove ( object  $object)

Removes an object to the persistence.

Parameters
object$object‪The object to remove

Implements TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface.

Definition at line 165 of file PersistenceManager.php.

◆ tearDown()

TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::tearDown ( )

Tear down the persistence

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.

Definition at line 253 of file PersistenceManager.php.

◆ update()

TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::update ( object  $object)

Update an object in the persistence.

Parameters
object$object‪The modified object
Exceptions

Implements TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface.

Definition at line 180 of file PersistenceManager.php.

References TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager\isNewObject().

Member Data Documentation

◆ $addedObjects

ObjectStorage TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::$addedObjects
protected

Definition at line 33 of file PersistenceManager.php.

◆ $backend

BackendInterface TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::$backend
protected

◆ $changedObjects

ObjectStorage TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::$changedObjects
protected

Definition at line 32 of file PersistenceManager.php.

◆ $newObjects

array TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::$newObjects = []
protected

Definition at line 31 of file PersistenceManager.php.

◆ $persistenceSession

Session TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::$persistenceSession
protected

◆ $queryFactory

QueryFactoryInterface TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::$queryFactory
protected

◆ $removedObjects

ObjectStorage TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::$removedObjects
protected

Definition at line 34 of file PersistenceManager.php.