本文整理汇总了PHP中PEAR_Frontend::singleton方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Frontend::singleton方法的具体用法?PHP PEAR_Frontend::singleton怎么用?PHP PEAR_Frontend::singleton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR_Frontend
的用法示例。
在下文中一共展示了PEAR_Frontend::singleton方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUI
function setUI($ui = null)
{
if (!$ui) {
$this->_ui = PEAR_Frontend::singleton();
} else {
$this->_ui = $ui;
}
}
示例2: init
function init(&$config, &$pkg, $lastversion)
{
$this->_config =& $config;
$this->_registry =& $config->getRegistry();
$this->_ui =& PEAR_Frontend::singleton();
$this->_pkg =& $pkg;
$this->_lastversion = $lastversion;
$this->_wwwDirectory = $this->_config->get('www_dir');
if ($this->_wwwDirectory === false || !file_exists($this->_wwwDirectory)) {
$this->_ui->log("Failed to find a web directory {$this->_wwwDirectory}");
return false;
}
$sfile = $this->_wwwDirectory . DIRECTORY_SEPARATOR . 'LocalSettings.php.sample';
$this->contents = file_get_contents($sfile, true);
if ($this->contents === false) {
$this->_ui->log("Failed to load '{$sfile}'");
return false;
}
$this->_ui->log("Loaded '{$sfile}'");
return true;
}
示例3: log
/**
* Logging method.
*
* @param int $level log level (0 is quiet, higher is noisier)
* @param string $msg message to write to the log
*
* @return void
*
* @access public
* @static
*/
function log($level, $msg, $append_crlf = true)
{
if ($this->debug >= $level) {
if (!class_exists('PEAR_Frontend')) {
require_once 'PEAR/Frontend.php';
}
$ui =& PEAR_Frontend::singleton();
if (is_a($ui, 'PEAR_Frontend')) {
$ui->log($msg, $append_crlf);
} else {
print "{$msg}\n";
}
}
}
示例4:
/**
* Get instance of frontend object.
*
* @return object|PEAR_Error
* @static
*/
function &getFrontendObject()
{
$a =& PEAR_Frontend::singleton();
return $a;
}
示例5: _addPackage2
/**
* @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
* @return bool
* @access private
*/
function _addPackage2($info)
{
if (!is_a($info, 'PEAR_PackageFile_v1') && !is_a($info, 'PEAR_PackageFile_v2')) {
return false;
}
if (!$info->validate()) {
if (class_exists('PEAR_Common')) {
$ui = PEAR_Frontend::singleton();
if ($ui) {
foreach ($info->getValidationWarnings() as $err) {
$ui->log($err['message'], true);
}
}
}
return false;
}
$channel = $info->getChannel();
$package = $info->getPackage();
$save = $info;
if ($this->_packageExists($package, $channel)) {
return false;
}
if (!$this->_channelExists($channel, true)) {
return false;
}
$info = $info->toArray(true);
if (!$info) {
return false;
}
$fp = $this->_openPackageFile($package, 'wb', $channel);
if ($fp === null) {
return false;
}
$info['_lastmodified'] = time();
fwrite($fp, serialize($info));
$this->_closePackageFile($fp);
$this->_rebuildFileMap();
return true;
}
示例6: listAll
function listAll($base, $dostable, $basic = true, $searchpackage = false, $searchsummary = false)
{
$packagelist = $this->_rest->retrieveData($base . 'p/packages.xml');
if (PEAR::isError($packagelist)) {
return $packagelist;
}
if ($this->_rest->config->get('verbose') > 0) {
$ui =& PEAR_Frontend::singleton();
$ui->log('Retrieving data...0%', false);
}
$ret = array();
if (!is_array($packagelist) || !isset($packagelist['p'])) {
return $ret;
}
if (!is_array($packagelist['p'])) {
$packagelist['p'] = array($packagelist['p']);
}
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$next = 0.1;
foreach ($packagelist['p'] as $progress => $package) {
if ($this->_rest->config->get('verbose') > 0) {
if ($progress / count($packagelist['p']) >= $next) {
if ($next == 0.5) {
$ui->log('50%', false);
} else {
$ui->log('.', false);
}
$next += 0.1;
}
}
if ($basic) {
// remote-list command
if ($dostable) {
$latest = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . '/stable.txt');
} else {
$latest = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . '/latest.txt');
}
if (PEAR::isError($latest)) {
$latest = false;
}
$info = array('stable' => $latest);
} else {
// list-all command
$inf = $this->_rest->retrieveData($base . 'p/' . strtolower($package) . '/info.xml');
if (PEAR::isError($inf)) {
PEAR::popErrorHandling();
return $inf;
}
if ($searchpackage) {
$found = !empty($searchpackage) && stristr($package, $searchpackage) !== false;
if (!$found && !(isset($searchsummary) && !empty($searchsummary) && (stristr($inf['s'], $searchsummary) !== false || stristr($inf['d'], $searchsummary) !== false))) {
continue;
}
}
$releases = $this->_rest->retrieveData($base . 'r/' . strtolower($package) . '/allreleases.xml');
if (PEAR::isError($releases)) {
continue;
}
if (!isset($releases['r'][0])) {
$releases['r'] = array($releases['r']);
}
unset($latest);
unset($unstable);
unset($stable);
unset($state);
foreach ($releases['r'] as $release) {
if (!isset($latest)) {
if ($dostable && $release['s'] == 'stable') {
$latest = $release['v'];
$state = 'stable';
}
if (!$dostable) {
$latest = $release['v'];
$state = $release['s'];
}
}
if (!isset($stable) && $release['s'] == 'stable') {
$stable = $release['v'];
if (!isset($unstable)) {
$unstable = $stable;
}
}
if (!isset($unstable) && $release['s'] != 'stable') {
$latest = $unstable = $release['v'];
$state = $release['s'];
}
if (isset($latest) && !isset($state)) {
$state = $release['s'];
}
if (isset($latest) && isset($stable) && isset($unstable)) {
break;
}
}
$deps = array();
if (!isset($unstable)) {
$unstable = false;
$state = 'stable';
if (isset($stable)) {
$latest = $unstable = $stable;
}
//.........这里部分代码省略.........
示例7: runPostinstallScripts
function runPostinstallScripts()
{
if ($this->initPostinstallScripts()) {
$ui =& PEAR_Frontend::singleton();
if ($ui) {
$ui->runPostinstallScripts($this->_scripts, $this);
}
}
}
示例8: array
// extreme debugging
exit;
}
}
// end print
$php_dir = $config->get('php_dir');
$options = array();
$options['upgrade'] = true;
$install_root = getenv('INSTALL_ROOT');
if (!empty($install_root)) {
$options['packagingroot'] = $install_root;
$reg =& new PEAR_Registry($options['packagingroot'], false, false, $metadata_dir);
} else {
$reg = $config->getRegistry('default');
}
$ui = PEAR_Frontend::singleton('PEAR_Frontend_CLI');
if (PEAR::isError($ui)) {
die($ui->getMessage());
}
$installer = new PEAR_Installer($ui);
$pkg = new PEAR_PackageFile($config, $debug);
foreach ($install_files as $package => $instfile) {
$info = $pkg->fromAnyFile($instfile, PEAR_VALIDATE_INSTALLING);
if (PEAR::isError($info)) {
if (is_array($info->getUserInfo())) {
foreach ($info->getUserInfo() as $err) {
$ui->outputData(sprintf("[PEAR] %s: %s", $package, $err['message']));
}
}
$ui->outputData(sprintf("[PEAR] %s: %s", $package, $info->getMessage()));
continue;
示例9: initializeFrontend
/**
* Initializes the PEAR Frontend instance.
*/
protected function initializeFrontend()
{
$this->frontend = PEAR_Frontend::singleton('sfPearFrontendPlugin');
if (PEAR::isError($this->frontend)) {
throw new sfPluginException(sprintf('Unable to initialize PEAR Frontend object: %s', $this->frontend->getMessage()));
}
$this->frontend->setEventDispatcher($this->dispatcher);
}
示例10: init
function init(&$config, &$pkg, $lastversion)
{
$this->_ui =& PEAR_Frontend::singleton();
$this->lastversion = $lastversion;
return true;
}
示例11: nativePearInstall
private function nativePearInstall($package, $channel)
{
if (!class_exists('PEAR_Command')) {
@(include 'PEAR/command.php');
// loads frontend, among other things
if (!class_exists('PEAR_Command')) {
throw new pakeException('PEAR subsystem is unavailable (not in include_path?)');
}
}
$front = PEAR_Frontend::singleton('PEAR_Frontend_CLI');
$cfg = PEAR_Config::singleton();
$cmd = PEAR_Command::factory('install', $cfg);
ob_start();
$result = $cmd->doInstall('install', array(), array($channel . '/' . $package));
ob_end_clean();
// we don't need output
if ($result instanceof PEAR_Error) {
throw new pakeException($result->getMessage());
}
}
示例12: log
/**
* Logging method.
*
* @param int $level log level (0 is quiet, higher is noisier)
* @param string $msg message to write to the log
*
* @return void
*
* @access public
* @static
*/
function log($level, $msg, $append_crlf = true)
{
if ($this->debug >= $level) {
$ui =& PEAR_Frontend::singleton();
if (is_a($ui, 'PEAR_Frontend')) {
$ui->log($msg, $append_crlf);
} else {
print "{$msg}\n";
}
}
}
示例13: nativePearUpgrade
private static function nativePearUpgrade($package, $channel)
{
pake_echo_action('pear', 'upgrading ' . $channel . '/' . $package);
self::initPearClasses();
$front = PEAR_Frontend::singleton('PEAR_Frontend_CLI');
$cfg = PEAR_Config::singleton();
$cmd = PEAR_Command::factory('upgrade', $cfg);
ob_start();
$result = $cmd->doInstall('upgrade', array(), array($channel . '/' . $package));
ob_end_clean();
// we don't need output
if ($result instanceof PEAR_Error) {
throw new pakeException($result->getMessage());
}
}