ZenMagick 0.9.6


org.zenmagick.ZMObject

Class ZMObject

ZMObject

public class ZMObject

ZenMagick base class.

This is the base class for all ZenMagick classes and contains some very basic stuff that might be usefull for most/all classes.

Included is generic support for properties via get($name), set($name, $value) and, via the corresponding methods __get($name) and __set($name,$value).

Author:
DerManoMann

Field Summary
protected mixed

$properties_

Constructor Summary

ZMObject()

Create new instance.

Method Summary
static void

attachMethod(string method, string className, mixed target)

Attach a dynamic method to objects.

mixed

get(string name, mixed default)

Support to access property values by name.

void

getAttachedMethods(array List)

Get all attached methods for this instance.

array

getPropertyNames()

Get a list of all custom properties.

void

set(string name, mixed value)

Support to set property values by name.

protected static mixed

singleton(string name, string instance)

Get a singleton instance of the named class.

Field Detail

properties_

protected mixed $properties_

Constructor Detail

ZMObject

public ZMObject()

Create new instance. /


Method Detail

attachMethod

public static void attachMethod(string method, string className, mixed target)

Attach a dynamic method to objects.

Target functions/methods have the following signature: ($ref, ...). $ref is the current instance ($this), and the remaining arguments are the actual call parameter.

Parameters:
method - The method name.
className - Name of the class to allow the method.
target - The target function or method.

get

public mixed get(string name, mixed default)

Support to access property values by name.

Parameters:
name - The property name.
default - A default value; default value is null.
Returns:
The value or null.

getAttachedMethods

public void getAttachedMethods(array List)

Get all attached methods for this instance.

Parameters:
List - of attached method names.

getPropertyNames

public array getPropertyNames()

Get a list of all custom properties.

Returns:
List of custom properties set on this object.

set

public void set(string name, mixed value)

Support to set property values by name.

Parameters:
name - The property name.
value - The value.

singleton

protected static mixed singleton(string name, string instance)

Get a singleton instance of the named class.

Parameters:
name - The class name.
instance - If set, register the given object, unless the name is already taken.
Returns:
A singleton object.

ZenMagick 0.9.6