class Session (View source)

deprecated since Flow 6.0

The persistence session - acts as a UoW and Identity Map for Flow's persistence framework.

Properties

protected SplObjectStorage $reconstitutedEntities

Reconstituted objects

protected array $reconstitutedEntitiesData

Reconstituted entity data (effectively their clean state)

protected SplObjectStorage $objectMap
protected array $identifierMap
protected ReflectionService $reflectionService

Methods

__construct()

Constructs a new Session

void
injectReflectionService(ReflectionService $reflectionService)

Injects a Reflection Service instance

void
registerReconstitutedEntity(object $entity, array $entityData)

Registers data for a reconstituted object.

void
replaceReconstitutedEntity(object $oldEntity, object $newEntity)

Replace a reconstituted object, leaves the clean data unchanged.

void
unregisterReconstitutedEntity(object $entity)

Unregisters data for a reconstituted object

getReconstitutedEntities()

Returns all objects which have been registered as reconstituted

bool
isReconstitutedEntity(object $entity)

Tells whether the given object is a reconstituted entity.

bool
isDirty(object $object, string $propertyName)

Checks whether the given property was changed in the object since it was reconstituted. Returns true for unknown objects in all cases!

bool
isMultiValuedPropertyDirty(array $cleanData, Traversable $currentValue)

Checks the $currentValue against the $cleanData.

bool
isSingleValuedPropertyDirty(string $type, mixed $previousValue, mixed $currentValue)

Checks the $previousValue against the $currentValue.

mixed
getCleanStateOfProperty(object $object, string $propertyName)

Returns the previous (last persisted) state of the property.

bool
hasObject(object $object)

Checks whether the given object is known to the identity map

bool
hasIdentifier(string $identifier)

Checks whether the given identifier is known to the identity map

object
getObjectByIdentifier(string $identifier)

Returns the object for the given identifier

string
getIdentifierByObject(object $object)

Returns the identifier for the given object either from the session, if the object was registered, or from the object itself using a special uuid property or the internal properties set by AOP.

registerObject(object $object, string $identifier)

Register an identifier for an object

void
unregisterObject(string $object)

Unregister an object

void
destroy()

Destroy the state of the persistence session and reset all internal data.

Details

__construct()

Constructs a new Session

void injectReflectionService(ReflectionService $reflectionService)

Injects a Reflection Service instance

Parameters

ReflectionService $reflectionService

Return Value

void

void registerReconstitutedEntity(object $entity, array $entityData)

Registers data for a reconstituted object.

$entityData format is described in "Documentation/PersistenceFramework object data format.txt"

Parameters

object $entity
array $entityData

Return Value

void

void replaceReconstitutedEntity(object $oldEntity, object $newEntity)

Replace a reconstituted object, leaves the clean data unchanged.

Parameters

object $oldEntity
object $newEntity

Return Value

void

void unregisterReconstitutedEntity(object $entity)

Unregisters data for a reconstituted object

Parameters

object $entity

Return Value

void

SplObjectStorage getReconstitutedEntities()

Returns all objects which have been registered as reconstituted

Return Value

SplObjectStorage

All reconstituted objects

bool isReconstitutedEntity(object $entity)

Tells whether the given object is a reconstituted entity.

Parameters

object $entity

Return Value

bool

bool isDirty(object $object, string $propertyName)

Checks whether the given property was changed in the object since it was reconstituted. Returns true for unknown objects in all cases!

Parameters

object $object
string $propertyName

Return Value

bool

protected bool isMultiValuedPropertyDirty(array $cleanData, Traversable $currentValue)

Checks the $currentValue against the $cleanData.

Parameters

array $cleanData
Traversable $currentValue

Return Value

bool

protected bool isSingleValuedPropertyDirty(string $type, mixed $previousValue, mixed $currentValue)

Checks the $previousValue against the $currentValue.

Parameters

string $type
mixed $previousValue
mixed $currentValue

Return Value

bool

mixed getCleanStateOfProperty(object $object, string $propertyName)

Returns the previous (last persisted) state of the property.

If nothing is found, NULL is returned.

Parameters

object $object
string $propertyName

Return Value

mixed

bool hasObject(object $object)

Checks whether the given object is known to the identity map

Parameters

object $object

Return Value

bool

bool hasIdentifier(string $identifier)

Checks whether the given identifier is known to the identity map

Parameters

string $identifier

Return Value

bool

object getObjectByIdentifier(string $identifier)

Returns the object for the given identifier

Parameters

string $identifier

Return Value

object

string getIdentifierByObject(object $object)

Returns the identifier for the given object either from the session, if the object was registered, or from the object itself using a special uuid property or the internal properties set by AOP.

Note: this returns an UUID 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

string

registerObject(object $object, string $identifier)

Register an identifier for an object

Parameters

object $object
string $identifier

void unregisterObject(string $object)

Unregister an object

Parameters

string $object

Return Value

void

void destroy()

Destroy the state of the persistence session and reset all internal data.

Return Value

void