Key-Value Coding protocol.
The basic idea behind KVC is to be able to manipulate "properties" of all objects with the same interface. The key is the property name. A keyPath is a dot-separated string of key chains to call. Example: $book->setValueForKey('Charles Dickens', 'name'); Example: $bookList->setValueForKeyPath('Charles Dickens', 'selection.author.name');
This class provides the interface for the Key-Value Coding informal protocol.
The WFObject has a default impementation of this interface that should be good for pretty much all of your subclasses.
Key Value Naming Conventions:
Getters: <key>(), get<Key>()
Setters: set<Key>($value)
Validators: validate<Key>( params )
Instance Var Names: <key>
Located in /framework/WFKeyValueCoding.php (line 43)
Get the value of a static keypath. A static keypath is a key called against a CLASS rather than an instance.
This function is a wrapper of valueForKeyPath that allows you to use KVC to access static methods/properties without having an instance to a class.
MyObject::valueForStaticKeyPath('MyObject::myStaticMethod')
Called by valueForStaticKey() if the key cannot be located through normal methods.
The default implementation raises as WFUndefinedKeyException. Subclasses can override this function to return an alternate value for the undefined key.
NOTE: subclass overrides probably won't work so well until PHP 5.3.
Set the value for the given key.
First tries to use a setter method (set<key>) then attempts access on class member.
Set the value for the given keyPath.
Set values for multiple keys.
Validate the value, calling the setter if the value is valid.
Validate the value, calling the setter if the value is valid.
Run the object-level validation code.
An object-level validator is used for interproperty validation, for instance validating 'postalCode' depends on 'country'.
The default implementation will call all defined Key-Value Validators (any method matching "^validate*").
Validations are done via validatedSetValueForKey(), meaning that changes made to values by the validators will be updated via setValueForKey.
Subclasses needing to do interproperty validation should override the validateObject() method. If subclasses wish to block the default behavior of re-validating all properties with validators, then the subclass should not call the super method. Subclasses wishing to preserve this behavior should call parent::validateObject($errors).
NOTE: It's called validateObject right now instead of validate primarily because Propel already has a validate() method.
Validate the given value for the given key.
Clients can normalize the value, and also report and error if the value is not valid.
If the value is valid without modificiation, return TRUE and do not alter $edited or $error. If the value is valid after being modified, return TRUE, and $edited to true. IF the value is not valid, do not alter $value or $edited, but fill out the $error object with desired information.
The default implementation (in WFObject) looks for a method named validate<key> and calls it, otherwise it returns TRUE.
Classes that wish to provide validators for keys should implement one validator per key, with the following prototype:
Validate the given value for the given keypath.
The default implementation (in WFObject) finds the target object based on the keypath and then calls the validateValueForKey method.
Get the value for the given key.
First tries to use a getter method (get<key>) then attempts access on class member.
Get the value for the given key path.
valueForKeypath's default implementation is in WFObject.
The default implementation does some very special things...
3. Static Method/Property access
If the first part of the keypath contains '::', then "static" mode will be enabled, which allows you to use KVC on an instance of an object to access static methods. Note that at present all static access must be done with valueForStaticKeyPath(). This may become more flexible in the future.
Called by valueForKey() if the key cannot be located through normal methods.
The default implementation raises as WFUndefinedKeyException. Subclasses can override this function to return an alternate value for the undefined key.
Creates an associative array with the set of passed keys and keyPaths and the corresponding values.
Creates an associative array with the set of passed keys and the corresponding values
Documentation generated on Thu, 14 May 2009 16:20:08 -0400 by phpDocumentor 1.4.2