interface PersistenceManagerInterface (View source)

The Flow Persistence Manager interface

Methods

void
injectSettings(array $settings)

Injects the Flow settings, called by Flow.

void
persistAll(bool $onlyAllowedObjects = false)

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

void
clearState()

Clears the in-memory state of the persistence.

bool
isNewObject(object $object)

Checks if the given object has ever been persisted.

void
registerNewObject(PersistenceMagicInterface $object)

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

mixed
getIdentifierByObject(object $object)

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

object|null
getObjectByIdentifier(mixed $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.

array
convertObjectToIdentityArray(object $object)

Converts the given object into an array containing the identity of the domain object.

array
convertObjectsToIdentityArrays(array $array)

Recursively iterates through the given array and turns objects into arrays containing the identity of the domain object.

createQueryForType(string $type)

Return a query object for the given type.

void
add(object $object)

Adds an object to the persistence.

void
remove(object $object)

Removes an object to the persistence.

void
update(object $object)

Update an object in the persistence.

void
whitelistObject(object $object) deprecated

Adds the given object to a list of allowed objects which may be persisted when persistAll() is called with the $onlyAllowedObjects flag. This is the case if "safe" HTTP request methods are used.

bool
isConnected()

Returns true, if an active connection to the persistence backend has been established, e.g. entities can be persisted.

bool
hasUnpersistedChanges()

Gives feedback if the persistence Manager has unpersisted changes.

Details

void injectSettings(array $settings)

Injects the Flow settings, called by Flow.

Parameters

array $settings

Return Value

void

void persistAll(bool $onlyAllowedObjects = false)

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

If $onlyAllowedObjects is set to true, only those objects which have been registered with allowObject() will be persisted. If other objects are in the queue, an exception will be raised.

Parameters

bool $onlyAllowedObjects

Return Value

void

void clearState()

Clears the in-memory state of the persistence.

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

Return Value

void

bool isNewObject(object $object)

Checks if the given object has ever been persisted.

Parameters

object $object

The object to check

Return Value

bool

true if the object is new, false if the object exists in the repository

void registerNewObject(PersistenceMagicInterface $object)

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

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.

Parameters

PersistenceMagicInterface $object

The new object to register

Return Value

void

mixed 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.

Parameters

object $object

Return Value

mixed

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

object|null getObjectByIdentifier(mixed $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

mixed $identifier
string $objectType
bool $useLazyLoading

Set to true if you want to use lazy loading for this object

Return Value

object|null

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

array convertObjectToIdentityArray(object $object)

Converts the given object into an array containing the identity of the domain object.

Parameters

object $object

The object to be converted

Return Value

array

The identity array in the format array('__identity' => '...')

Exceptions

UnknownObjectException

array convertObjectsToIdentityArrays(array $array)

Recursively iterates through the given array and turns objects into arrays containing the identity of the domain object.

Parameters

array $array

The array to be iterated over

Return Value

array

The modified array without objects

Exceptions

UnknownObjectException

See also

convertObjectToIdentityArray()

QueryInterface createQueryForType(string $type)

Return a query object for the given type.

Parameters

string $type

Return Value

QueryInterface

void add(object $object)

Adds an object to the persistence.

Parameters

object $object

The object to add

Return Value

void

void remove(object $object)

Removes an object to the persistence.

Parameters

object $object

The object to remove

Return Value

void

void update(object $object)

Update an object in the persistence.

Parameters

object $object

The modified object

Return Value

void

Exceptions

UnknownObjectException

void whitelistObject(object $object) deprecated

deprecated Use allowObject() instead. See https://github.com/neos/flow-development-collection/pull/2024

Adds the given object to a list of allowed objects which may be persisted when persistAll() is called with the $onlyAllowedObjects flag. This is the case if "safe" HTTP request methods are used.

Parameters

object $object

The object

Return Value

void

bool isConnected()

Returns true, if an active connection to the persistence backend has been established, e.g. entities can be persisted.

Return Value

bool

true, if an connection has been established, false if add object will not be persisted by the backend

bool hasUnpersistedChanges()

Gives feedback if the persistence Manager has unpersisted changes.

This is primarily used to inform the user if he tries to save data in an unsafe request.

Return Value

bool