PHP Interface Neos\Flow\Persistence\PersistenceManagerInterface

Datei anzeigen Open project: neos/flow-development-collection Interface Usage Examples

Public Methods

Method Description
add ( object $object ) : void Adds an object to the persistence.
clearState ( ) : void Clears the in-memory state of the persistence.
convertObjectToIdentityArray ( object $object ) : array Converts the given object into an array containing the identity of the domain object.
convertObjectsToIdentityArrays ( array $array ) : array Recursively iterates through the given array and turns objects into arrays containing the identity of the domain object.
createQueryForType ( string $type ) : Neos\Flow\Persistence\QueryInterface Return a query object for the given type.
getIdentifierByObject ( object $object ) : mixed Returns the (internal) identifier for the object, if it is known to the backend. Otherwise NULL is returned.
getObjectByIdentifier ( mixed $identifier, string $objectType = null, boolean $useLazyLoading = false ) : object Returns the object with the (internal) identifier, if it is known to the backend. Otherwise NULL is returned.
hasUnpersistedChanges ( ) : boolean Gives feedback if the persistence Manager has unpersisted changes.
injectSettings ( array $settings ) : void Injects the Flow settings, called by Flow.
isConnected ( ) : boolean Returns TRUE, if an active connection to the persistence backend has been established, e.g. entities can be persisted.
isNewObject ( object $object ) : boolean Checks if the given object has ever been persisted.
persistAll ( boolean $onlyWhitelistedObjects = false ) : void Commits new objects and changes to objects in the current persistence session into the backend.
registerNewObject ( Aspect\PersistenceMagicInterface $object ) : void Registers an object which has been created or cloned during this request.
remove ( object $object ) : void Removes an object to the persistence.
update ( object $object ) : void Update an object in the persistence.
whitelistObject ( object $object ) : void Adds the given object to a whitelist of objects which may be persisted when persistAll() is called with the $onlyWhitelistedObjects flag. This is the case if "safe" HTTP request methods are used.

Method Details

add() public method

Adds an object to the persistence.
public add ( object $object ) : void
$object object The object to add
return void

clearState() public method

Managed instances become detached, any fetches will return data directly from the persistence "backend".
public clearState ( ) : void
return void

convertObjectToIdentityArray() public method

Converts the given object into an array containing the identity of the domain object.
public convertObjectToIdentityArray ( object $object ) : array
$object object The object to be converted
return array The identity array in the format array('__identity' => '...')

convertObjectsToIdentityArrays() public method

Recursively iterates through the given array and turns objects into arrays containing the identity of the domain object.
See also: convertObjectToIdentityArray()
public convertObjectsToIdentityArrays ( array $array ) : array
$array array The array to be iterated over
return array The modified array without objects

createQueryForType() public method

Return a query object for the given type.
public createQueryForType ( string $type ) : Neos\Flow\Persistence\QueryInterface
$type string
return Neos\Flow\Persistence\QueryInterface

getIdentifierByObject() public method

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.
public getIdentifierByObject ( object $object ) : mixed
$object object
return mixed The identifier for the object if it is known, or NULL

getObjectByIdentifier() public method

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, boolean $useLazyLoading = false ) : object
$identifier mixed
$objectType string
$useLazyLoading boolean Set to TRUE if you want to use lazy loading for this object
return object The object for the identifier if it is known, or NULL

hasUnpersistedChanges() public method

This is primarily used to inform the user if he tries to save data in an unsafe request.
public hasUnpersistedChanges ( ) : boolean
return boolean

injectSettings() public method

Injects the Flow settings, called by Flow.
public injectSettings ( array $settings ) : void
$settings array
return void

isConnected() public method

Returns TRUE, if an active connection to the persistence backend has been established, e.g. entities can be persisted.
public isConnected ( ) : boolean
return boolean TRUE, if an connection has been established, FALSE if add object will not be persisted by the backend

isNewObject() public method

Checks if the given object has ever been persisted.
public isNewObject ( object $object ) : boolean
$object object The object to check
return boolean TRUE if the object is new, FALSE if the object exists in the repository

persistAll() public method

If $onlyWhitelisteObjects is set to TRUE, only those objects which have been registered with whitelistObject() will be persisted. If other objects are in the queue, an exception will be raised.
public persistAll ( boolean $onlyWhitelistedObjects = false ) : void
$onlyWhitelistedObjects boolean
return void

registerNewObject() public method

The given object must contain the Persistence_Object_Identifier property, thus the PersistenceMagicInterface type hint. 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.
public registerNewObject ( Aspect\PersistenceMagicInterface $object ) : void
$object Aspect\PersistenceMagicInterface The new object to register
return void

remove() public method

Removes an object to the persistence.
public remove ( object $object ) : void
$object object The object to remove
return void

update() public method

Update an object in the persistence.
public update ( object $object ) : void
$object object The modified object
return void

whitelistObject() public method

Adds the given object to a whitelist of objects which may be persisted when persistAll() is called with the $onlyWhitelistedObjects flag. This is the case if "safe" HTTP request methods are used.
public whitelistObject ( object $object ) : void
$object object The object
return void