ZenMagick 0.9.6


org.zenmagick.misc.ZMBeanUtils

Class ZMBeanUtils

ZMBeanUtils

public class ZMBeanUtils

Bean/model utilities.

Author:
DerManoMann
Version:
$Id: ZMBeanUtils.php 2123 2009-03-31 09:22:29Z dermanomann $

Method Summary
static mixed

getBean(string definition)

Build an object based on the bean definition.

protected array

getPropertyMap(mixed obj, array properties)

Get the property mapping for a given class/object.

static mixed

map2obj(string clazz, array data, array keys)

Create a new instance of the given class and populate with the provided data.

static array

obj2map(mixed obj, array properties, mixed addGeneric, addGeneric Optional)

Convert an object into a map.

static void

setAll(mixed obj, array data, array keys, mixed setGeneric, setGeneric Optional)

Set a given map of key/value pairs on an object.

Method Detail

getBean

public static mixed getBean(string definition)

Build an object based on the bean definition.

The syntax for bean definitions is: [class name]#[property1=value1&property2=value2&...].

Parameters:
definition - The bean definition.
Returns:
An object or null.

getPropertyMap

protected array getPropertyMap(mixed obj, array properties)

Get the property mapping for a given class/object.

If explicitely set (via $properties), generic properties will be considered too.

Parameters:
obj - The class instance.
properties - Optional list of properties to use; default is null for all.
Returns:
A property / method map.

map2obj

public static mixed map2obj(string clazz, array data, array keys)

Create a new instance of the given class and populate with the provided data.

Parameters:
clazz - The class name.
data - The data map.
keys - Optional list of data keys to be used; default is null to use all.
Returns:
An instance of the given class or null.

obj2map

public static array obj2map(mixed obj, array properties, mixed addGeneric, addGeneric Optional)

Convert an object into a map.

If explicitely set (via $properties), generic properties will be considered, even if $addGeneric is set to false.

Parameters:
obj - The class instance.
properties - Optional list of properties to use; default is null for all.
Optional - flag to indicate whether generic ZMObject properties should be * included or not; default is true to include generic properties.
Returns:
The object data as map.

setAll

public static void setAll(mixed obj, array data, array keys, mixed setGeneric, setGeneric Optional)

Set a given map of key/value pairs on an object.

Parameters:
obj - The class instance.
data - The data map.
keys - Optional list of data keys to be used; default is null to use all.
Optional - flag to indicate whether generic ZMObject properties should be * included or not; default is true to include generic properties.

ZenMagick 0.9.6