/** * Gets a Piece_ORM_Config object from a cache. * * @param string $masterFile * @param string $cacheDirectory * @return Piece_ORM_Config */ function &_getConfiguration($masterFile, $cacheDirectory) { $masterFile = realpath($masterFile); $cache =& new Cache_Lite_File(array('cacheDir' => "{$cacheDirectory}/", 'masterFile' => $masterFile, 'automaticSerialization' => true, 'errorHandlingAPIBreak' => true)); if (!Piece_ORM_Env::isProduction()) { $cache->remove($masterFile); } /* * The Cache_Lite class always specifies PEAR_ERROR_RETURN when * calling PEAR::raiseError in default. */ $config = $cache->get($masterFile); if (PEAR::isError($config)) { trigger_error("Cannot read the cache file in the directory [ {$cacheDirectory} ].", E_USER_WARNING); return Piece_ORM_Config_Factory::_createConfigurationFromFile($masterFile); } if (!$config) { $config =& Piece_ORM_Config_Factory::_createConfigurationFromFile($masterFile); $result = $cache->save($config); if (PEAR::isError($result)) { trigger_error("Cannot write the Piece_ORM_Config object to the cache file in the directory [ {$cacheDirectory} ].", E_USER_WARNING); } } return $config; }