Detailed Description
PersistentObject defines the interface of all persistent objects.
It mainly requires an unique identifier for each instance (ObjectId), tracking of the persistent state, methods for setting and getting values as well as callback methods for lifecycle events.
Definition at line 23 of file PersistentObject.php.
Public Member Functions | |
getType () | |
getMapper () | |
getOID () | |
setOID (ObjectId $oid) | |
getState () | |
setState ($state) | |
delete () | |
__clone () | |
copyValues (PersistentObject $object, $copyPkValues=true) | |
mergeValues (PersistentObject $object) | |
clearValues () | |
reset () | |
afterCreate () | |
beforeInsert () | |
afterInsert () | |
afterLoad () | |
beforeUpdate () | |
afterUpdate () | |
beforeDelete () | |
afterDelete () | |
getValue ($name) | |
setValue ($name, $value, $forceSet=false, $trackChange=true) | |
hasValue ($name) | |
removeValue ($name) | |
getValueNames ($excludeTransient=false) | |
validateValues () | |
validateValue ($name, $value) | |
getChangedValues () | |
getOriginalValue ($name) | |
getIndispensableObjects () | |
getProperty ($name) | |
setProperty ($name, $value) | |
getPropertyNames () | |
getValueProperty ($name, $property) | |
setValueProperty ($name, $property, $value) | |
getValuePropertyNames ($name) | |
getDisplayValue () | |
dump () | |
Public Attributes | |
const | STATE_CLEAN = 0 |
const | STATE_DIRTY = 1 |
const | STATE_NEW = 2 |
const | STATE_DELETED = 3 |
Member Function Documentation
◆ getType()
getType | ( | ) |
Get the type of the object.
- Returns
- The objects type.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ getMapper()
getMapper | ( | ) |
Get the PersistenceMapper of the object.
- Returns
- PersistenceMapper
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ getOID()
getOID | ( | ) |
Get the object id of the PersistentObject.
- Returns
- ObjectId
Implemented in DefaultPersistentObject, PersistentObjectProxy, and NullNode.
◆ setOID()
setOID | ( | ObjectId | $oid | ) |
Set the object id of the PersistentObject.
- Parameters
-
$oid The PersistentObject's oid.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ getState()
getState | ( | ) |
Get the object's state:
- Returns
- One of the STATE constant values:
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ setState()
setState | ( | $state | ) |
Set the state of the object to one of the STATE constants.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ delete()
delete | ( | ) |
Delete the object.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ __clone()
__clone | ( | ) |
Get a copy of the object (ChangeListeners and Lock are not copied)
- Returns
- PersistentObject
Implemented in DefaultPersistentObject, PersistentObjectProxy, and Node.
◆ copyValues()
copyValues | ( | PersistentObject | $object, |
$copyPkValues = true |
|||
) |
Copy all non-empty values to a given instance (ChangeListeners are triggered)
- Parameters
-
$object PersistentObject instance to copy the values to. $copyPkValues Boolean whether primary key values should be copied
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ mergeValues()
mergeValues | ( | PersistentObject | $object | ) |
Copy all values, that don't exist yet from a given instance (ChangeListeners are not triggered)
- Parameters
-
$object PersistentObject instance to copy the values from.
Implemented in DefaultPersistentObject, Node, and PersistentObjectProxy.
◆ clearValues()
clearValues | ( | ) |
Clear all values.
Set each value to null except for the primary key values
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ reset()
reset | ( | ) |
Reset all values to their original values.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ afterCreate()
afterCreate | ( | ) |
This method is called once after creation of this object.
At this time it is not known in the store.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ beforeInsert()
beforeInsert | ( | ) |
This method is called once before inserting the newly created object into the store.
Implemented in DefaultPersistentObject, PersistentObjectProxy, and AbstractUser.
◆ afterInsert()
afterInsert | ( | ) |
This method is called once after inserting the newly created object into the store.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ afterLoad()
afterLoad | ( | ) |
This method is called always after loading the object from the store.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ beforeUpdate()
beforeUpdate | ( | ) |
This method is called always before updating the modified object in the store.
Implemented in DefaultPersistentObject, PersistentObjectProxy, and AbstractUser.
◆ afterUpdate()
afterUpdate | ( | ) |
This method is called always after updating the modified object in the store.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ beforeDelete()
beforeDelete | ( | ) |
This method is called once before deleting the object from the store.
Implemented in DefaultPersistentObject, PersistentObjectProxy, and AbstractUser.
◆ afterDelete()
afterDelete | ( | ) |
This method is called once after deleting the object from the store.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ getValue()
getValue | ( | $name | ) |
Get the value of an attribute.
- Parameters
-
$name The name of the attribute.
- Returns
- The value of the attribute / null if it doesn't exist.
Implemented in DefaultPersistentObject, PersistentObjectProxy, and Node.
◆ setValue()
setValue | ( | $name, | |
$value, | |||
$forceSet = false , |
|||
$trackChange = true |
|||
) |
Set the value of an attribute if it exists.
- Parameters
-
$name The name of the attribute to set. $value The value of the attribute. $forceSet Boolean whether to set the value even if it is already set and to bypass validation (used to notify listeners) (default: false) $trackChange Boolean whether to track the change (change state, notify listeners) or not (default: true) Only set this false, if you know, what you are doing
- Returns
- Boolean whether the operation succeeds or not
Implemented in DefaultPersistentObject, PersistentObjectProxy, AbstractUser, and Node.
◆ hasValue()
hasValue | ( | $name | ) |
Check if the object has a given attribute.
- Parameters
-
$name The name of the attribute.
- Returns
- Boolean whether the attribute exists or not.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ removeValue()
removeValue | ( | $name | ) |
Remove an attribute.
- Parameters
-
$name The name of the attribute to remove.
Implemented in DefaultPersistentObject, PersistentObjectProxy, and Node.
◆ getValueNames()
getValueNames | ( | $excludeTransient = false | ) |
Get the names of all attributes.
- Parameters
-
$excludeTransient Boolean whether to exclude transient values (default: false)
- Returns
- An array of attribute names.
Implemented in DefaultPersistentObject, PersistentObjectProxy, and Node.
◆ validateValues()
validateValues | ( | ) |
Validate all values by calling PersistentObject::validateValue() Throws a ValidationException in case of invalid data.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ validateValue()
validateValue | ( | $name, | |
$value | |||
) |
Check if data may be set.
The method is also called, when setting a value. Controller may call this method before setting data and saving the object. Throws a ValidationException in case of invalid data.
- Parameters
-
$name The name of the attribute to set. $value The value of the attribute. The default implementation calls PersistentObject::validateValueAgainstValidateType().
Implemented in DefaultPersistentObject, PersistentObjectProxy, AbstractUser, and AbstractRole.
◆ getChangedValues()
getChangedValues | ( | ) |
Get the list of changed attributes since creation, loading.
- Returns
- Array of value names
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ getOriginalValue()
getOriginalValue | ( | $name | ) |
Get the original of an attribute provided to the initialize method.
- Parameters
-
$name The name of the attribute.
- Returns
- The value of the attribute / null if it doesn't exist.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ getIndispensableObjects()
getIndispensableObjects | ( | ) |
Get the list of objects that must exist in the store, before this object may be persisted.
Implementing classes may use this method to manage dependencies.
- Returns
- Array of PersistentObject instances
Implemented in DefaultPersistentObject, PersistentObjectProxy, and Node.
◆ getProperty()
getProperty | ( | $name | ) |
Get the value of a named property in the object.
- Parameters
-
$name The name of the property.
- Returns
- The value of the property / null if it doesn't exist.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ setProperty()
setProperty | ( | $name, | |
$value | |||
) |
Set the value of a named property in the object.
- Parameters
-
$name The name of the property to set. $value The value of the property to set.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ getPropertyNames()
getPropertyNames | ( | ) |
Get the names of all properties in the object.
Properties are either defined by using the PersistentObject::setProperty() method or by the PersistentMapper.
- Returns
- An array consisting of the names.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ getValueProperty()
getValueProperty | ( | $name, | |
$property | |||
) |
Get the value of one property of an attribute.
- Parameters
-
$name The name of the attribute to get its properties. $property The name of the property to get.
- Returns
- The value property/null if not found.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ setValueProperty()
setValueProperty | ( | $name, | |
$property, | |||
$value | |||
) |
Set the value of one property of an attribute.
- Parameters
-
$name The name of the attribute to set its properties. $property The name of the property to set. $value The value to set on the property.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ getValuePropertyNames()
getValuePropertyNames | ( | $name | ) |
Get the names of all properties of a value in the object.
- Returns
- An array consisting of the names.
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
◆ getDisplayValue()
getDisplayValue | ( | ) |
Get the value of the object used for display.
- Returns
- The value.
Implemented in Node, DefaultPersistentObject, and PersistentObjectProxy.
◆ dump()
dump | ( | ) |
Get a string representation of the values of the PersistentObject.
- Returns
- String
Implemented in DefaultPersistentObject, and PersistentObjectProxy.
Member Data Documentation
◆ STATE_CLEAN
const STATE_CLEAN = 0 |
Definition at line 25 of file PersistentObject.php.
◆ STATE_DIRTY
const STATE_DIRTY = 1 |
Definition at line 26 of file PersistentObject.php.
◆ STATE_NEW
const STATE_NEW = 2 |
Definition at line 27 of file PersistentObject.php.
◆ STATE_DELETED
const STATE_DELETED = 3 |
Definition at line 28 of file PersistentObject.php.