ZenMagick 0.9.8


org.zenmagick.core.utils.ZMBeanUtils
\core\utils\ZMBeanUtils.php at line 43

Class ZMBeanUtils

ZMObject
└─ZMBeanUtils

public class ZMBeanUtils
extends ZMObject

Bean utility.

Bean definitions and properties handled by this class may use two special (magic) name prefixes to create/set objects rather than strings:

bean::
The string (without the prefix) will be taken as bean definition; special case is a bean definition of null which will be converted to a PHP null.
ref::
This prefix indicates that the following string is to be taken as bean definition. However, the instance created/obtained will first be looked up as singleton instance. It is important to remember that by setting properties on references these settings will be permanent for all subsequent code using that singleton.

Author:
DerManoMann
Version:
$Id: ZMBeanUtils.php 2783 2009-12-28 22:03:57Z dermanomann $

Fields inherited from org.zenmagick.core.ZMObject
properties_
Method Summary
static mixed

getBean(string definition)

Build an object based on the bean definition.

static 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 mixed

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

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

Methods inherited from org.zenmagick.core.ZMObject
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Method Detail

\core\utils\ZMBeanUtils.php at line 191

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.

\core\utils\ZMBeanUtils.php at line 58

getPropertyMap

public static 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.

\core\utils\ZMBeanUtils.php at line 174

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.

\core\utils\ZMBeanUtils.php at line 105

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.

\core\utils\ZMBeanUtils.php at line 146

setAll

public static mixed 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 or array.
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.
Returns:
The (modified) $obj.

ZenMagick 0.9.8