PersistentObject Interface Reference

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.

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 23 of file PersistentObject.php.

+ Inheritance diagram for PersistentObject:

Public Member Functions

 getType ()
 
 getMapper ()
 
 getOID ()
 
 setOID (ObjectId $oid)
 
 getState ()
 
 setState ($state)
 
 delete ()
 
 __clone ()
 
 copyValues (PersistentObject $object, $copyPkValues=true)
 
 mergeValues (PersistentObject $object)
 
 clearValues ()
 
 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 ()
 
 getOriginalValues ()
 
 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 ( )

Get the type of the object.

Returns
The objects type.

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

getMapper ( )

Get the PersistenceMapper of the object.

Returns
PersistenceMapper

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

getOID ( )

Get the object id of the PersistentObject.

Returns
ObjectId

Implemented in DefaultPersistentObject, PersistentObjectProxy, and NullNode.

setOID ( ObjectId  $oid)

Set the object id of the PersistentObject.

Parameters
$oidThe PersistentObject's oid.

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

getState ( )

Get the object's state:

Returns
One of the STATE constant values:

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

setState (   $state)

Set the state of the object to one of the STATE constants.

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

delete ( )

Delete the object.

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

__clone ( )

Get a copy of the object (ChangeListeners and Lock are not copied)

Returns
PersistentObject

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

copyValues ( PersistentObject  $object,
  $copyPkValues = true 
)

Copy all non-empty values to a given instance (ChangeListeners are triggered)

Parameters
$objectPersistentObject instance to copy the values to.
$copyPkValuesBoolean whether primary key values should be copied

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

mergeValues ( PersistentObject  $object)

Copy all values, that don't exist yet from a given instance (ChangeListeners are not triggered)

Parameters
$objectPersistentObject instance to copy the values from.

Implemented in DefaultPersistentObject, Node, and PersistentObjectProxy.

clearValues ( )

Clear all values.

Set each value to null except for the primary key values

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

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 ( )

This method is called once before inserting the newly created object into the store.

Implemented in DefaultPersistentObject, PersistentObjectProxy, and AbstractUser.

afterInsert ( )

This method is called once after inserting the newly created object into the store.

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

afterLoad ( )

This method is called always after loading the object from the store.

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

beforeUpdate ( )

This method is called always before updating the modified object in the store.

Implemented in DefaultPersistentObject, PersistentObjectProxy, and AbstractUser.

afterUpdate ( )

This method is called always after updating the modified object in the store.

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

beforeDelete ( )

This method is called once before deleting the object from the store.

Implemented in DefaultPersistentObject, PersistentObjectProxy, and AbstractUser.

afterDelete ( )

This method is called once after deleting the object from the store.

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

getValue (   $name)

Get the value of an attribute.

Parameters
$nameThe name of the attribute to query.
Returns
The value of the attribute / null if it doesn't exits.

Implemented in DefaultPersistentObject, PersistentObjectProxy, and Node.

setValue (   $name,
  $value,
  $forceSet = false,
  $trackChange = true 
)

Set the value of an attribute if it exists.

Parameters
$nameThe name of the attribute to set.
$valueThe value of the attribute.
$forceSetBoolean whether to set the value even if it is already set and to bypass validation (used to notify listeners) (default: false)
$trackChangeBoolean 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 (   $name)

Check if the object has a given attribute.

Parameters
$nameThe name of the attribute to query.
Returns
Boolean whether the attribute exists or not.

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

removeValue (   $name)

Remove an attribute.

Parameters
$nameThe name of the attribute to remove.

Implemented in DefaultPersistentObject, PersistentObjectProxy, and Node.

getValueNames (   $excludeTransient = false)

Get the names of all attributes.

Parameters
$excludeTransientBoolean whether to exclude transient values (default: false)
Returns
An array of attribute names.

Implemented in DefaultPersistentObject, PersistentObjectProxy, and Node.

validateValues ( )

Validate all values by calling PersistentObject::validateValue() Throws a ValidationException in case of invalid data.

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

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
$nameThe name of the attribute to set.
$valueThe value of the attribute. The default implementation calls PersistentObject::validateValueAgainstValidateType().

Implemented in DefaultPersistentObject, PersistentObjectProxy, AbstractUser, and AbstractRole.

getChangedValues ( )

Get the list of changed attributes since creation, loading.

Returns
Array of value names

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

getOriginalValues ( )

Get the original data provided to the initialize method.

Returns
Associative array with value names as keys and values as values

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

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 (   $name)

Get the value of a named property in the object.

Parameters
$nameThe name of the property to query.
Returns
The value of the property / null if it doesn't exits.

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

setProperty (   $name,
  $value 
)

Set the value of a named property in the object.

Parameters
$nameThe name of the property to set.
$valueThe value of the property to set.

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

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 (   $name,
  $property 
)

Get the value of one property of an attribute.

Parameters
$nameThe name of the attribute to get its properties.
$propertyThe name of the property to get.
Returns
The value property/null if not found.

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

setValueProperty (   $name,
  $property,
  $value 
)

Set the value of one property of an attribute.

Parameters
$nameThe name of the attribute to set its properties.
$propertyThe name of the property to set.
$valueThe value to set on the property.

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

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 ( )

Get the value of the object used for display.

Returns
The value.

Implemented in Node, DefaultPersistentObject, and PersistentObjectProxy.

dump ( )

Get a string representation of the values of the PersistentObject.

Returns
String

Implemented in DefaultPersistentObject, and PersistentObjectProxy.

Member Data Documentation

const STATE_CLEAN = 0

Definition at line 25 of file PersistentObject.php.

const STATE_DIRTY = 1

Definition at line 26 of file PersistentObject.php.

const STATE_NEW = 2

Definition at line 27 of file PersistentObject.php.

const STATE_DELETED = 3

Definition at line 28 of file PersistentObject.php.