Public Member Functions | Protected Member Functions | Protected Attributes

Robo47_Application_Resource_Object Class Reference

List of all members.

Public Member Functions

 getObject ()
 Get Object.
 init ()

Protected Member Functions

 _callFunction ($object, $name, array $params=array())
 Calls a function on a object with params.
 _callFunctions ($object, array $functions=array())
 Calls functions on a object.
 _initObject ($class, array $params=array())
 Init Object.
 _setStaticVariable ($classname, $name, $value)
 Set static variable on a class.
 _setStaticVariables ($classname, $variables)
 Set static variables on a class.
 _setupObject ($options)
 Setup object based on classname, params, variables and calling methods.
 _setVariable ($object, $name, $value)
 Set a variable on an object.
 _setVariables ($object, array $variables=array())
 Sets variables on an object.

Protected Attributes

 $_object = null

Detailed Description

Definition at line 31 of file Object.php.


Member Function Documentation

Robo47_Application_Resource_Object::_callFunction ( object,
name,
array $  params = array() 
) [protected]

Calls a function on a object with params.

Parameters:
object|string $object
string $name
array $params
Returns:
Robo47_Application_Resource_Object *Provides Fluent Interface*

Definition at line 221 of file Object.php.

    {
        call_user_func_array(array($object, $name), $params);
        return $this;
    }

Robo47_Application_Resource_Object::_callFunctions ( object,
array $  functions = array() 
) [protected]

Calls functions on a object.

Parameters:
object $object
array $functions
Returns:
Robo47_Application_Resource_Object *Provides Fluent Interface*

Definition at line 188 of file Object.php.

Referenced by _setupObject().

    {
        foreach ($functions as $function) {
            if (isset($function[0]) &&
                is_string($function[0])) {

                $func = $function[0];
                $params = array();
                if (isset($function[1])) {
                    $params = $function[1];
                }
                if (is_array($params)) {
                    $this->_callFunction($object, $func, $params);
                } else {
                    $message = 'invalid parameters for function ' . $func;
                    throw new Robo47_Application_Resource_Exception($message);
                }
            } else {
                $message = 'no valid functionname found on function';
                throw new Robo47_Application_Resource_Exception($message);
            }
        }
        return $this;
    }

Here is the caller graph for this function:

Robo47_Application_Resource_Object::_initObject ( class,
array $  params = array() 
) [protected]

Init Object.

Parameters:
string $class
array $params
Returns:
object

Definition at line 142 of file Object.php.

Referenced by _setupObject().

    {
        $ref = new Zend_Reflection_Class($class);
        if (!empty($params)) {
            return $ref->newInstanceArgs($params);
        } else {
            return $ref->newInstance();
        }
    }

Here is the caller graph for this function:

Robo47_Application_Resource_Object::_setStaticVariable ( classname,
name,
value 
) [protected]

Set static variable on a class.

Parameters:
string $classname
string $name
mixed $value
Returns:
Robo47_Application_Resource_Object *Provides Fluent Interface*

Definition at line 128 of file Object.php.

Referenced by _setStaticVariables().

    {
        $ref = new ReflectionClass($classname);
        $ref->setStaticPropertyValue($name, $value);
        return $this;
    }

Here is the caller graph for this function:

Robo47_Application_Resource_Object::_setStaticVariables ( classname,
variables 
) [protected]

Set static variables on a class.

Parameters:
string $classname
string $variable
mixed $value

Definition at line 112 of file Object.php.

References _setStaticVariable().

Referenced by _setupObject().

    {
        foreach ($variables as $name => $value) {
            $this->_setStaticVariable($classname, $name, $value);
        }
        return $this;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Robo47_Application_Resource_Object::_setupObject ( options  )  [protected]

Setup object based on classname, params, variables and calling methods.

Parameters:
array $options
Returns:
object

Definition at line 60 of file Object.php.

References _callFunctions(), _initObject(), _setStaticVariables(), and _setVariables().

Referenced by init().

    {
        if (!isset($options['classname'])) {
            $message = 'no classname found for Object resource';
            throw new Robo47_Application_Resource_Exception($message);
        }

        if (!isset($options['params'])) {
            $object = $this->_initObject($options['classname']);
        } else {
            $object = $this->_initObject(
                $options['classname'],
                $options['params']
            );
        }

        if (isset($options['variables'])) {
            $this->_setVariables($object, $options['variables']);
        }

        if (isset($options['staticVariables'])) {
            $this->_setStaticVariables(
                $options['classname'],
                $options['staticVariables']
            );
        }

        if (isset($options['functions'])) {
            $this->_callFunctions($object, $options['functions']);
        }

        if (isset($options['staticFunctions'])) {
            $this->_callFunctions(
                $options['classname'],
                $options['staticFunctions']
            );
        }

        if (isset($options['registryKey'])) {
            Zend_Registry::set($options['registryKey'], $object);
        }

        return $object;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Robo47_Application_Resource_Object::_setVariable ( object,
name,
value 
) [protected]

Set a variable on an object.

Parameters:
object $object
string $name
mixed $value
Returns:
Robo47_Application_Resource_Object *Provides Fluent Interface*

Definition at line 175 of file Object.php.

Referenced by _setVariables().

    {
        $object->{$name} = $value;
        return $this;
    }

Here is the caller graph for this function:

Robo47_Application_Resource_Object::_setVariables ( object,
array $  variables = array() 
) [protected]

Sets variables on an object.

Parameters:
object $object
array $variables
Returns:
Robo47_Application_Resource_Object *Provides Fluent Interface*

Definition at line 159 of file Object.php.

References _setVariable().

Referenced by _setupObject().

    {
        foreach ($variables as $variable => $value) {
            $this->_setVariable($object, $variable, $value);
        }
        return $this;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Robo47_Application_Resource_Object::getObject (  ) 

Get Object.

Returns:
object

Definition at line 232 of file Object.php.

    {
        return $this->_object;
    }

Robo47_Application_Resource_Object::init (  ) 

Definition at line 43 of file Object.php.

References _setupObject().

    {
        if (!empty($this->_options)) {
            $this->_object = $this->_setupObject($this->_options);
        } else {
            $message = 'Empty options in resource ' .
                'Robo47_Application_Resource_Object.';
            throw new Robo47_Application_Resource_Exception($message);
        }
    }

Here is the call graph for this function:


Member Data Documentation

Robo47_Application_Resource_Object::$_object = null [protected]

Definition at line 38 of file Object.php.


The documentation for this class was generated from the following file: