本文整理汇总了PHP中eZCLI::warning方法的典型用法代码示例。如果您正苦于以下问题:PHP eZCLI::warning方法的具体用法?PHP eZCLI::warning怎么用?PHP eZCLI::warning使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZCLI
的用法示例。
在下文中一共展示了eZCLI::warning方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeMessage
/**
* Displays a message on the appropriate output (cli or eZDebug)
*
* @param string $msg
* @param string $logType
*/
public static function writeMessage($msg, $logType = self::NOTICELOG)
{
self::$cli = eZCLI::instance();
$isWebOutput = self::$cli->isWebOutput();
switch ($logType) {
case self::ERRORLOG:
if (!$isWebOutput) {
self::$cli->error($msg);
} else {
eZDebug::writeError($msg, 'SQLIImport');
}
break;
case self::WARNINGLOG:
if (!$isWebOutput) {
self::$cli->warning($msg);
} else {
eZDebug::writeWarning($msg, 'SQLIImport');
}
break;
case self::NOTICELOG:
default:
if (!$isWebOutput) {
self::$cli->notice($msg);
} else {
eZDebug::writeNotice($msg, 'SQLIImport');
}
break;
}
}
示例2: showReplies
/**
* @param array $possibleReplies
* @param array $alreadyChosen
*/
function showReplies ( $possibleReplies, $alreadyChosen = array() )
{
if ( count($possibleReplies) > 0 )
{
$this->cli->output( "Expected Reply between [ ]" );
foreach ( $possibleReplies as $label => $description )
{
if ( in_array($label, $alreadyChosen) )
{
$this->cli->warning( " * [$label] : $description" );
}
else
{
$this->cli->output( " [$label] : $description" );
}
}
}
}
示例3: internalClear
private function internalClear($purge, $cacheEntries, $name, $purgeSleep = null, $purgeMax = null, $purgeExpiry = null)
{
$this->cli->output(($purge ? 'Purging ' : 'Clearing ') . $this->cli->stylize('emphasize', $name ? $name : 'All cache') . ': ');
$warnPaths = array();
foreach ($cacheEntries as $cacheEntry) {
$absPath = realpath(eZSys::cacheDirectory() . DIRECTORY_SEPARATOR . $cacheEntry['path']);
$absPathElementCount = count(explode(DIRECTORY_SEPARATOR, rtrim($absPath, DIRECTORY_SEPARATOR)));
// Refuse to delete root directory ('/' or 'C:\')
// 2 => since one path element ('/foo') produces two exploded elements
if ($absPath && $absPathElementCount < 2) {
$this->cli->error('Refusing to delete root directory! Please check your cache settings. Path: ' . $absPath);
$this->script->shutdown(1);
exit;
}
// Warn if the cache entry is not function based, and the path is outside ezp root, and the path has less than 2 elements
if ($absPath && (!$purge || !isset($cacheEntry['purge-function'])) && !isset($cacheEntry['function']) && $absPathElementCount < 3 && strpos(dirname($absPath) . DIRECTORY_SEPARATOR, realpath(eZSys::rootDir()) . DIRECTORY_SEPARATOR) === false) {
$warnPaths[] = $absPath;
}
}
if (!empty($warnPaths)) {
$this->cli->warning('The following cache paths are outside of the eZ Publish root directory, and have less than 2 path elements. ' . 'Are you sure you want to ' . ($purge ? 'purge' : 'clear') . ' them?');
foreach ($warnPaths as $warnPath) {
$this->cli->output($warnPath);
}
if (function_exists("getUserInput")) {
$input = getUserInput(($purge ? 'Purge' : 'Clear') . '? yes/no:', array('yes', 'no'));
} else {
$validInput = false;
$readlineExists = function_exists("readline");
while (!$validInput) {
if ($readlineExists) {
$input = readline($query);
} else {
echo $prompt . ' ';
$input = trim(fgets(STDIN));
}
if ($acceptValues === false || in_array($input, $acceptValues)) {
$validInput = true;
}
}
}
if ($input === 'no') {
$this->script->shutdown();
exit;
}
}
$firstItem = true;
foreach ($cacheEntries as $cacheEntry) {
if ($firstItem) {
$firstItem = false;
} else {
$this->cli->output(', ', false);
}
$this->cli->output($this->cli->stylize('emphasize', $cacheEntry['name']), false);
if ($purge) {
eZCache::clearItem($cacheEntry, true, array($this, 'reportProgress'), $purgeSleep, $purgeMax, $purgeExpiry);
} else {
eZCache::clearItem($cacheEntry);
}
}
$this->cli->output();
}
示例4: computeOffsetByFork
/**
* @param eZCLI $cli
* @param eZDBInterface $db
* @param string $cronPart
* @param int $maxRetries
* @return int offset to use or -1 if an error occures
*/
function computeOffsetByFork ( $cli, $db, $cronPart, $maxRetries )
{
// Normal case
if (!preg_match('#^[a-zA-Z_]+(\d)#', $cronPart, $match))
{
return 0;
}
$ezfindIni = eZINI::instance('ezfind.ini');
$maxForks = $ezfindIni->variable('IndexOptions', 'MaxPendingForkCount');
$matchOffset = $match[1] - 1;
if ( $matchOffset > $maxForks )
{
$cli->output( "Ini setting states you can't run more than $maxForks forks, you try to run fork #" . ($matchOffset + 1) );
return -1;
}
$countQuery = "SELECT count(id) as nb_pending FROM ezpending_actions WHERE action = 'index_object' AND ( param_int IS NULL OR param_int <= $maxRetries )";
$result = $db->arrayQuery($countQuery);
if ( !$result || !isset($result[0]['nb_pending']))
{
$cli->error("Mysql unexpected error. Script will be stopped.");
return -1;
}
$forkInterval = $ezfindIni->variable('IndexOptions', 'MinPendingForkInterval');
$pendingCount = $result[0]['nb_pending'];
$forkMinCount = $matchOffset * $forkInterval;
if ($pendingCount < $forkMinCount)
{
$cli->warning( "Trying to run pending fork #$matchOffset but we have less than $forkMinCount pending objects. Script will be stopped.");
return -1;
}
$offset = max($forkMinCount, round($pendingCount/$maxForks) * $matchOffset);
$cli->output( "Fork #" . ($matchOffset + 1) . " starting at offset #$offset");
return $offset;
}
示例5: runImport
/**
* Starts to run the import
* @param array( SQLIImportItem ) $aImportItems
* @throws SQLIImportBaseException
* @throws ezcConfigurationNoConfigException
*/
public function runImport(array $aImportItems)
{
// First check if an import is already running
if (SQLIImportToken::importIsRunning()) {
throw new SQLIImportBaseException('Another import is already running. Aborting...', SQLIImportBaseException::IMPORT_ALREADY_RUNNING);
}
$this->token = SQLIImportToken::registerNewImport();
$this->handlePerformanceSettings();
if (empty($aImportItems)) {
// If no source handler is provided, consider processing all source handlers available
$aImportItems = $this->importINI->variable('ImportSettings', 'AvailableSourceHandlers');
}
// Process import items one by one
for ($i = 0, $iMax = count($aImportItems); $i < $iMax; ++$i) {
try {
if (!$aImportItems[$i] instanceof SQLIImportItem) {
throw new SQLIImportRuntimeException('Invalid import item !');
}
// Update status for import item
$aImportItems[$i]->setAttribute('status', SQLIImportItem::STATUS_RUNNING);
$aImportItems[$i]->store();
$this->currentImportItem = $aImportItems[$i];
// First check if this handler has all needed configuration
$handler = $aImportItems[$i]->attribute('handler');
$handlerSection = $handler . '-HandlerSettings';
if (!$this->importINI->hasSection($handlerSection)) {
// Check INI Section
throw new ezcConfigurationNoConfigException('Error : Handler "' . $handler . '" does not have proper config section in sqliimport.ini !');
}
if (!$this->importINI->hasVariable($handlerSection, 'ClassName')) {
// Check if ClassName is properly defined
throw new ezcConfigurationNoConfigException('Error : ClassName not defined for "' . $handler . '" in sqliimport.ini !');
}
// Default values
$handlerClassName = $this->importINI->variable($handlerSection, 'ClassName');
$handlerEnabled = true;
$debug = false;
$defaultParentNodeID = $this->importINI->variable('ImportSettings', 'DefaultParentNodeID');
$streamTimeout = $this->importINI->variable('ImportSettings', 'StreamTimeout');
if ($this->importINI->hasVariable($handlerSection, 'Enabled')) {
$handlerEnabled = $this->importINI->variable($handlerSection, 'Enabled') === 'true';
}
if ($this->importINI->hasVariable($handlerSection, 'Debug')) {
$debug = $this->importINI->variable($handlerSection, 'Debug') === 'enabled';
}
if ($this->importINI->hasVariable($handlerSection, 'DefaultParentNodeID')) {
$localParentNodeID = $this->importINI->variable($handlerSection, 'DefaultParentNodeID');
$defaultParentNodeID = is_int($localParentNodeID) ? (int) $localParentNode : $defaultParentNodeID;
}
if ($this->importINI->hasVariable($handlerSection, 'StreamTimeout')) {
$streamTimeout = (int) $this->importINI->variable($handlerSection, 'StreamTimeout');
}
// Check $defaultParentNodeID and throw an exception if not consistent
$parentNode = eZContentObjectTreeNode::fetch($defaultParentNodeID, false, false);
if (!$parentNode) {
throw new SQLIImportRuntimeException('Error : invalid DefaultParentNodeID ( ' . $defaultParentNodeID . ' )');
}
unset($parentNode);
// Check handler class validity
if (!class_exists($handlerClassName)) {
throw new SQLIImportRuntimeException('Error : invalid handler class "' . $handlerClassName . '". Did you regenerate autolads ?');
}
// ####################################
// ##### IMPORT HANDLER PROCESSING
// ####################################
// Instantiate the handler with appropriate options and process it.
// Handler must implement ISQLIImportHandler and extend SQLIImportAbstractHandler
$handlerOptions = $aImportItems[$i]->attribute('options');
$importHandler = new $handlerClassName($handlerOptions);
if (!$importHandler instanceof ISQLIImportHandler || !$importHandler instanceof SQLIImportAbstractHandler) {
throw new SQLIImportRuntimeException('Error : invalid handler "' . $handlerClassName . '". Must implement ISQLIImportHandler and extend SQLIImportAbstractHandler.');
}
$importHandler->handlerConfArray = $this->importINI->group($handlerSection);
$importHandler->initialize();
// Get process length to calculate advancement percentage to track advancement
$processLength = $importHandler->getProcessLength();
$percentageAdvancementStep = 100 / $processLength;
$handlerName = $importHandler->getHandlerName();
$handlerIdentifier = $importHandler->getHandlerIdentifier();
// Progress bar implementation
$progressBarOptions = array('emptyChar' => ' ', 'barChar' => '=');
$progressBar = new ezcConsoleProgressbar($this->output, $processLength, $progressBarOptions);
$progressBar->start();
$this->cli->warning('Now processing "' . $handlerName . '" handler.');
$isInterrupted = false;
while ($row = $importHandler->getNextRow()) {
try {
$progressBar->advance();
$startTime = time();
$importHandler->process($row);
} catch (Exception $e) {
SQLIImportLogger::logError('An error occurred during "' . $handlerIdentifier . '" import process : ' . $e->getMessage());
}
$aImportItems[$i]->updateProgress($percentageAdvancementStep, $importHandler->getProgressionNotes());
//.........这里部分代码省略.........
示例6: updateArticleImportStatus
function updateArticleImportStatus($importStatusId, $dryRun = false, eZCLI $cli = null, $statusMddEz = 0)
{
$query = "UPDATE import_status SET status_mdd_ez = '%s' WHERE id = '%s'";
$query = sprintf($query, $statusMddEz, $importStatusId);
if ($dryRun)
{
$cli->warning($query);
return;
}
XMLImportDB::query($query);
}