PersistenceManager
class PersistenceManager extends AbstractPersistenceManager (View source)
Flow's Doctrine PersistenceManager
Properties
protected array | $settings | from AbstractPersistenceManager | |
protected array | $newObjects | from AbstractPersistenceManager | |
protected bool | $hasUnpersistedChanges | from AbstractPersistenceManager | |
protected AllowedObjectsContainer | $allowedObjects | from AbstractPersistenceManager | |
protected LoggerInterface | $logger | ||
protected ThrowableStorageInterface | $throwableStorage | ||
protected EntityManagerInterface | $entityManager | ||
protected ValidatorResolver | $validatorResolver | ||
protected ReflectionService | $reflectionService |
Methods
Injects the Flow settings, the persistence part is kept for further use.
Clears the in-memory state of the persistence.
Registers an object which has been created or cloned during this request.
Adds the given object to a list of allowed objects which may be persisted even if the current HTTP request is considered a "safe" request.
Converts the given object into an array containing the identity of the domain object.
Recursively iterates through the given array and turns objects into an arrays containing the identity of the domain object.
Gives feedback if the persistence Manager has unpersisted changes.
Injects the (system) logger based on PSR-3.
Commits new objects and changes to objects in the current persistence session into the backend
Commits new objects and changes to objects in the current persistence session into the backend.
Checks if the given object has ever been persisted.
Returns the (internal) identifier for the object, if it is known to the backend. Otherwise NULL is returned.
Returns the object with the (internal) identifier, if it is known to the backend. Otherwise NULL is returned.
Return a query object for the given type.
Adds an object to the persistence.
Removes an object to the persistence.
Update an object in the persistence.
Returns true, if an active connection to the persistence backend has been established, e.g. entities can be persisted.
Called from functional tests, creates/updates database tables and compiles proxies.
Called after a functional test in Flow, dumps everything in the database.
Signals that all persistAll() has been executed successfully.
Details
void
injectSettings(array $settings)
Injects the Flow settings, the persistence part is kept for further use.
void
clearState()
Clears the in-memory state of the persistence.
Managed instances become detached, any fetches will return data directly from the persistence "backend".
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.
void
allowObject(object $object)
Adds the given object to a list of allowed objects which may be persisted even if the current HTTP request is considered a "safe" request.
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 an arrays containing the identity of the domain object.
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.
void
injectLogger(LoggerInterface $logger)
Injects the (system) logger based on PSR-3.
void
persistAll(bool $onlyAllowedObjects = false)
Commits new objects and changes to objects in the current persistence session into the backend
void
persistAllowedObjects()
Commits new objects and changes to objects in the current persistence session into the backend.
An exception will be thrown if there are scheduled updates/deletes or insertions for objects that are not "allowed" (see AbstractPersistenceManager::allowObject())
bool
isNewObject(object $object)
Checks if the given object has ever been persisted.
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.
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.
QueryInterface
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.
bool
isConnected()
Returns true, if an active connection to the persistence backend has been established, e.g. entities can be persisted.
bool
compile()
Called from functional tests, creates/updates database tables and compiles proxies.
void
tearDown()
Called after a functional test in Flow, dumps everything in the database.
protected void
emitAllObjectsPersisted()
Signals that all persistAll() has been executed successfully.