library/Garp/Spawn/Php/Model/Base.php
protected function _convertToArray($obj) {
        $arr    = array();
        $arrObj = is_object($obj) ? get_object_vars($obj) : $obj;

        foreach ($arrObj as $key => $val) {
            if (is_object($val)) {
                switch (get_class($val)) {
                case 'Garp_Spawn_Relation_Set':
                    $val = $val->getRelations();
                    break;
                case 'Garp_Spawn_Behaviors':
                    $val = $val->getBehaviors();
                    break;
                case 'Garp_Spawn_Fields':
                    $val = $val->getFields();
                }

                $val = $this->_convertToArray($val);
            } elseif (is_array($val)) {
                $val = $this->_convertToArray($val);
            }
            $arr[$key] = $val;
        }

        return $arr;
    }
protected function _convertToArray($obj) {
        $arr    = array();
        $arrObj = is_object($obj) ? get_object_vars($obj) : $obj;

        foreach ($arrObj as $key => $val) {
            if (is_object($val)) {
                switch (get_class($val)) {
                case 'Garp_Spawn_Relation_Set':
                    $val = $val->getRelations();
                    break;
                case 'Garp_Spawn_Behaviors':
                    $val = $val->getBehaviors();
                    break;
                case 'Garp_Spawn_Fields':
                    $val = $val->getFields();
                }

                $val = $this->_convertToArray($val);
            } elseif (is_array($val)) {
                $val = $this->_convertToArray($val);
            }
            $arr[$key] = $val;
        }

        return $arr;
    }
protected function _convertToArray ( $ obj ) { $ arr = array ( ) ; $ arrObj = is_object ( $ obj ) ? get_object_vars ( $ obj ) : $ obj ; foreach ( $ arrObj as $ key => $ val ) { if ( is_object ( $ val ) ) { switch ( get_class ( $ val ) ) { case 'Garp_Spawn_Relation_Set' : $ val = $ val -> getRelations ( ) ; break ; case 'Garp_Spawn_Behaviors' : $ val = $ val -> getBehaviors ( ) ; break ; case 'Garp_Spawn_Fields' : $ val = $ val -> getFields ( ) ; } $ val = $ this -> _convertToArray ( $ val ) ; } elseif ( is_array ( $ val ) ) { $ val = $ this -> _convertToArray ( $ val ) ; } $ arr [ $ key ] = $ val ; } return $ arr ; }
Extracts the public properties from an iteratable object

@param mixed $obj    At first, feed this a Garp_Spawn_Model_Abstract, after which
it calls itself with an array.
@return array
Extracts the public properties from an iteratable object