/** * Creates an instance of the given update class. * * @access public * @param string $driver The type of PPU to create. * @param string $packageName The package to update. * @param string $channel The channel the package resides on. * @return object An instance of type PEAR_PackageUpdate_$driver * @since 0.4.0a1 * @throws PEAR_PACKAGEUPDATE_ERROR_NONEXISTENTDRIVER */ function &factory($driver, $packageName, $channel) { $class = 'PEAR_PackageUpdate_' . $driver; // Attempt to include a custom version of the named class, but don't treat // a failure as fatal. The caller may have already included their own // version of the named class. if (!class_exists($class)) { // Try to include the driver. $file = 'PEAR/PackageUpdate/' . $driver . '.php'; if (!PEAR_PackageUpdate::isIncludable($file)) { PEAR_ErrorStack::staticPush('PEAR_PackageUpdate', PEAR_PACKAGEUPDATE_ERROR_NONEXISTENTDRIVER, null, array('drivername' => $driver), $GLOBALS['_PEAR_PACKAGEUPDATE_ERRORS'][PEAR_PACKAGEUPDATE_ERROR_NONEXISTENTDRIVER]); // Must assign a variable to avoid notice about references. $false = false; return $false; } include_once $file; } // See if the class exists now. if (!class_exists($class)) { // Must assign a variable to avoid notice about references. $false = false; return $false; } // Try to instantiate the class. $instance =& new $class($packageName, $channel); return $instance; }
} $pearweb_channel =& PEAR_PackageUpdate::factory('Cli', 'pearweb_channelxml', 'pear.php.net'); if ($pearweb_channel) { $pearweb_channel->setMinimumState(PEAR_PACKAGEUPDATE_STATE_STABLE); if ($pearweb_channel->checkUpdate()) { if (!$pearweb_channel->update()) { if ($pearweb_channel->hasErrors()) { $errors = PEAR_ErrorStack::staticGetErrors(); echo "errors\n"; foreach ($errors['PEAR_PackageUpdate_Cli'] as $err) { echo $err['message'] . "\n"; } } } } } $pearweb_gopear =& PEAR_PackageUpdate::factory('Cli', 'pearweb_gopear', 'pear.php.net'); if ($pearweb_gopear) { $pearweb_gopear->setMinimumState(PEAR_PACKAGEUPDATE_STATE_STABLE); if ($pearweb_gopear->checkUpdate()) { if (!$pearweb_gopear->update()) { if ($pearweb_gopear->hasErrors()) { $errors = PEAR_ErrorStack::staticGetErrors(); echo "errors\n"; foreach ($errors['PEAR_PackageUpdate_Cli'] as $err) { echo $err['message'] . "\n"; } } } } }