src/xPDO/Cache/xPDOCacheManager.php
public function generateObject($obj, $objName, $generateObjVars= false, $generateRelated= false, $objRef= 'this->xpdo', $format= xPDOCacheManager::CACHE_PHP) {
        $source= false;
        if (is_object($obj) && $obj instanceof \xPDO\Om\xPDOObject) {
            $className= $obj->_class;
            $source= "\${$objName}= \${$objRef}->newObject('{$className}');\n";
            $source .= "\${$objName}->fromArray(" . var_export($obj->toArray('', true), true) . ", '', true, true);\n";
            if ($generateObjVars && $objectVars= get_object_vars($obj)) {
                foreach ($objectVars as $vk => $vv) {
                    if ($vk === 'modx') {
                        $source .= "\${$objName}->{$vk}= & \${$objRef};\n";
                    }
                    elseif ($vk === 'xpdo') {
                        $source .= "\${$objName}->{$vk}= & \${$objRef};\n";
                    }
                    elseif (!is_resource($vv)) {
                        $source .= "\${$objName}->{$vk}= " . var_export($vv, true) . ";\n";
                    }
                }
            }
            if ($generateRelated && !empty ($obj->_relatedObjects)) {
                foreach ($obj->_relatedObjects as $className => $fk) {
                    foreach ($fk as $key => $relObj) {} /* TODO: complete $generateRelated functionality */
                }
            }
        }
        return $source;
    }
public function generateObject($obj, $objName, $generateObjVars= false, $generateRelated= false, $objRef= 'this->xpdo', $format= xPDOCacheManager::CACHE_PHP) {
        $source= false;
        if (is_object($obj) && $obj instanceof \xPDO\Om\xPDOObject) {
            $className= $obj->_class;
            $source= "\${$objName}= \${$objRef}->newObject('{$className}');\n";
            $source .= "\${$objName}->fromArray(" . var_export($obj->toArray('', true), true) . ", '', true, true);\n";
            if ($generateObjVars && $objectVars= get_object_vars($obj)) {
                foreach ($objectVars as $vk => $vv) {
                    if ($vk === 'modx') {
                        $source .= "\${$objName}->{$vk}= & \${$objRef};\n";
                    }
                    elseif ($vk === 'xpdo') {
                        $source .= "\${$objName}->{$vk}= & \${$objRef};\n";
                    }
                    elseif (!is_resource($vv)) {
                        $source .= "\${$objName}->{$vk}= " . var_export($vv, true) . ";\n";
                    }
                }
            }
            if ($generateRelated && !empty ($obj->_relatedObjects)) {
                foreach ($obj->_relatedObjects as $className => $fk) {
                    foreach ($fk as $key => $relObj) {} /* TODO: complete $generateRelated functionality */
                }
            }
        }
        return $source;
    }
public function generateObject ( $ obj , $ objName , $ generateObjVars = false , $ generateRelated = false , $ objRef = 'this->xpdo' , $ format = xPDOCacheManager :: CACHE_PHP ) { $ source = false ; if ( is_object ( $ obj ) && $ obj instanceof \ xPDO \ Om \ xPDOObject ) { $ className = $ obj -> _class ; $ source = "\${$objName}= \${$objRef}->newObject('{$className}');\n" ; $ source .= "\${$objName}->fromArray(" . var_export ( $ obj -> toArray ( '' , true ) , true ) . ", '', true, true);\n" ; if ( $ generateObjVars && $ objectVars = get_object_vars ( $ obj ) ) { foreach ( $ objectVars as $ vk => $ vv ) { if ( $ vk === 'modx' ) { $ source .= "\${$objName}->{$vk}= & \${$objRef};\n" ; } elseif ( $ vk === 'xpdo' ) { $ source .= "\${$objName}->{$vk}= & \${$objRef};\n" ; } elseif ( ! is_resource ( $ vv ) ) { $ source .= "\${$objName}->{$vk}= " . var_export ( $ vv , true ) . ";\n" ; } } } if ( $ generateRelated && ! empty ( $ obj -> _relatedObjects ) ) { foreach ( $ obj -> _relatedObjects as $ className => $ fk ) { foreach ( $ fk as $ key => $ relObj ) { } /* TODO: complete $generateRelated functionality */ } } } return $ source ; }
Generate a PHP executable representation of an xPDOObject.

@todo Complete $generateRelated functionality.
@todo Add stdObject support.

@access public
@param \xPDO\Om\xPDOObject $obj An xPDOObject to generate the cache file for
@param string $objName The name of the xPDOObject
@param boolean $generateObjVars If true, will also generate maps for all
object variables. Defaults to false.
@param boolean $generateRelated If true, will also generate maps for all
related objects. Defaults to false.
@param string $objRef The reference to the xPDO instance, in string
format.
@param int $format The format to cache in. Defaults to
xPDOCacheManager::CACHE_PHP, which is set to cache in executable PHP format.
@return string The source map file, in string format.
Generate a PHP executable representation of an xPDOObject .