CleanStateTracker
final class \
Keeps the original (clean) property values of Extbase entities and compares them with the current values to find out whether an entity has been changed.
The method names follow the concepts of the Doctrine ORM UnitOfWork: original entity data and entity
change set. The original data is kept per object in a WeakMap of this service, not in the entity. An entity
that has original data is managed by the persistence layer. An object without original data, for example a
clone or an unserialized entity, is not managed: It has no original data, no change set and is never dirty.
The original data is not cleared with the persistence state, it is gone when its object is garbage collected.
Internal
only to be used within Extbase, not part of TYPO3 Core API.
Attributes
- #[Autoconfigure]
- $public: true
Table of Contents
Methods
- __construct() : mixed
- contains() : bool
- Returns whether original data was registered for the object, which means that it is managed by the persistence layer.
- getEntityChangeSet() : array<non-empty-string, array{mixed, mixed}>
- Returns the changed properties of the entity as `property => [original value, current value]`.
- getOriginalEntityData() : array<non-empty-string, mixed>
- Returns the original values of the entity, or an empty array if none were registered.
- isEntityDirty() : bool
- Returns whether any property of the entity differs from its original value. An `ObjectStorage` is dirty if it was modified since its modified flag was reset.
- isEntityPropertyDirty() : bool
- Returns whether the given property of the entity differs from its original value.
- setOriginalEntityData() : void
- Registers the current values of all persistable properties of the entity as its original data. For an `ObjectStorage` this resets its modified flag.
- setOriginalEntityProperty() : void
- Registers the current value of one property of the entity as its original value.
Methods
__construct()
public
__construct() : mixed
contains()
Returns whether original data was registered for the object, which means that it is managed by the persistence layer.
public
contains(object $entity) : bool
Parameters
- $entity : object
Return values
boolgetEntityChangeSet()
Returns the changed properties of the entity as `property => [original value, current value]`.
public
getEntityChangeSet(object $entity) : array<non-empty-string, array{mixed, mixed}>
Parameters
- $entity : object
Tags
Return values
array<non-empty-string, array{mixed, mixed}>getOriginalEntityData()
Returns the original values of the entity, or an empty array if none were registered.
public
getOriginalEntityData(object $entity) : array<non-empty-string, mixed>
Parameters
- $entity : object
Return values
array<non-empty-string, mixed>isEntityDirty()
Returns whether any property of the entity differs from its original value. An `ObjectStorage` is dirty if it was modified since its modified flag was reset.
public
isEntityDirty(object $entity) : bool
Parameters
- $entity : object
Tags
Return values
boolisEntityPropertyDirty()
Returns whether the given property of the entity differs from its original value.
public
isEntityPropertyDirty(object $entity, non-empty-string $propertyName) : bool
Parameters
- $entity : object
- $propertyName : non-empty-string
Tags
Return values
boolsetOriginalEntityData()
Registers the current values of all persistable properties of the entity as its original data. For an `ObjectStorage` this resets its modified flag.
public
setOriginalEntityData(object $entity) : void
Parameters
- $entity : object
setOriginalEntityProperty()
Registers the current value of one property of the entity as its original value.
public
setOriginalEntityProperty(object $entity, non-empty-string $propertyName) : void
Parameters
- $entity : object
- $propertyName : non-empty-string