|
|
Manual and Documentation
NOTE: This manual describes HammerKit version 3.5. To view documentation for the current release of HammerKit Studio, please go to http://manual.hammerkit.com/ |
|
|
|
|
|
|
|
|
|
|
|
|
/ / Classes |
|
|
|
|
|
|
|
|
|
|
Creating objects
Objects are created by using the new keyword. A color object with the database id 34 is created in the following way:
$color_object = new HammerKit_Color(34);
Object attributes
All HammerKit objects have attributes that are either settable or not settable. The value for an attribute can always be fetched by the HammerKit_ObjectInterface method getAttribute(string attribute_name [, boolean formatted [, array format_options]]):
$attribute_value = $object->getAttribute('attribute_name');
Settable attributes' values can also be fetched directly from an object's variable:
$attribute_value = $object->attribute_name;
It is recommended that attribute values always be fetched through the getAttribute() method. When fetching a settable attribute's value directly from the object's variable the value is always in a non-formatted form. When fetching an attribute value through the getAttribute() method the
returned value is always formatted by default. By setting the second
parameter of getAttribute() to FALSE, the returned value is not
formatted.
Object attributes are typed, which helps in sorting and formatting the attribute values. When fetching the value for an attribute of type array the array keys are separated by a period ".". Because of this the attribute names cannot contain periods. For instance fetching the value of a file variable with name "varname" could be done with the getAttribute() method like this:
$attribute_value = $file_object->getAttribute('variables.varname');
Possible HammerKit_Object attribute types are:
- Scalar types:
- boolean
- float
- integer
- string
- Pseudo-types:
- HammerKit_Object types:
- HammerKit_Color
- HammerKit_Component
- HammerKit_Element
- HammerKit_File
- HammerKit_Keyword
- HammerKit_User
- HammerKit_UserGroup
All of these types can be represented as arrays by appending the type name with square brackets []. If the array contains only x number of items the number is added inside the brackets. For instance a type that is an array of integers with 5 elements would be marked "integer[5]". No value inside the brackets means unlimited number of items in the array.
Class Names before HammerKit v4
In HammerKit v4 all internal class names are prefixed with the string 'HammerKit_' to make the class names globally unique. All global labels (class, function and variable names) starting with 'HammerKit_' are thus reserved for HammerKit's internal use. Module and tool writers must not create global labels starting with 'HammerKit_'.
In HammerKit v3 releases all the internal class names were named as in v4 without the leading 'HammerKit_'. For example the class HammerKit_Component in v4 is just Component in HammerKit v3 releases. An exception is the HammerKit_UserGroup class which in v3 releases was named Usergroup with a lower-case g. This was in conflict with the class naming rule where all separate words in the class name are marked with an upper-case first letter.
|
� HammerKit Oy 2008 |
UPDATED: 09.12.2008 10:42 |
|