本文整理汇总了PHP中yii\helpers\Console::error方法的典型用法代码示例。如果您正苦于以下问题:PHP Console::error方法的具体用法?PHP Console::error怎么用?PHP Console::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Console
的用法示例。
在下文中一共展示了Console::error方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showErrors
/**
* Show errors
* @param array $errors array of errors string
* @throws yii\base\ExitException
*/
protected function showErrors($errors)
{
foreach ((array) $errors as $err) {
Console::error(Console::ansiFormat(Yii::t('activeuser_backend', "Error") . ": ", [Console::FG_RED]) . $err[0]);
}
yii::$app->end();
}
示例2: export
/**
* @inheritdoc
*/
public function export()
{
foreach ($this->messages as $message) {
if ($message[1] == Logger::LEVEL_ERROR) {
Console::error($this->formatMessage($message));
} else {
Console::output($this->formatMessage($message));
}
}
}
示例3: actionHandle
/**
* @param string $command serialized command object
* @return string
*/
public function actionHandle($command)
{
try {
$command = unserialize(base64_decode($command));
$command->setRunningInBackground(true);
$this->commandBus->handle($command);
} catch (\Exception $e) {
Console::error($e->getMessage());
}
}
示例4: actionReplaceSourceLanguage
/**
* @param $path
* @param bool $newSourceLanguage
* @param bool $configFile
* @throws Exception
*/
public function actionReplaceSourceLanguage($configFile, $newSourceLanguage = false)
{
$config = ['translator' => 'Yii::t', 'overwrite' => false, 'removeUnused' => false, 'sort' => false, 'format' => 'php'];
$configFile = Yii::getAlias($configFile);
if (!is_file($configFile)) {
throw new Exception("The configuration file does not exist: {$configFile}");
}
$config = array_merge($config, require $configFile);
if (!is_dir($config['sourcePath'])) {
throw new Exception("The source path {$config['sourcePath']} is not a valid directory.");
}
$files = FileHelper::findFiles(realpath($config['sourcePath']), $config);
$unremoved = [];
foreach ($files as $fileName) {
if (!is_array($config['translator'])) {
$translator = [$config['translator']];
}
foreach ($translator as $currentTranslator) {
$n = 0;
$subject = file_get_contents($fileName);
$replacedSubject = preg_replace_callback('/\\b(\\\\)?' . $currentTranslator . '\\s*\\(\\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\\s*,\\s*(\'.*?(?<!\\\\)\'|".*?(?<!\\\\)")\\s*[,\\)]/s', function ($matches) use($newSourceLanguage, $fileName, &$unremoved) {
$category = substr($matches[2], 1, -1);
$message = $matches[3];
if ($newSourceLanguage !== false) {
$message = eval("return {$message};");
$result = str_replace($message, Yii::t($category, $message, [], $newSourceLanguage), $matches[0]);
} else {
if (strpos($matches[0], ')') != strlen($matches[0]) - 1) {
$unremoved[$fileName][] = $message;
$result = $matches[0];
} else {
$result = $message;
}
}
return $result;
}, $subject, -1, $n);
if (@file_put_contents($fileName, $replacedSubject) !== false) {
Console::output("File: {$fileName}; Translator: {$currentTranslator}; Affected: {$n}");
} else {
Console::error("File: {$fileName}; Translator: {$currentTranslator}; Affected: {$n}");
}
}
}
if ($newSourceLanguage == false && !empty($unremoved)) {
Console::output('Messages with params, can`t be removed by this tool. Remove it manually');
foreach ($unremoved as $fileName => $messages) {
$messages = implode(PHP_EOL, $messages);
Console::output("{$fileName}:" . PHP_EOL . $messages);
}
}
}
示例5: execute
public function execute($command, $params = [])
{
$command = strtr($command, $params);
$exec = $this->getExec();
try {
if ($this->getIsVerbose()) {
Console::output("Executing {$command}");
}
$result = $exec($command);
if ($this->getIsVerbose()) {
Console::output($result);
}
return $result;
} catch (\RuntimeException $e) {
Console::error($e->getMessage());
return false;
}
}
示例6: onError
/**
* @param $exception
* @param $job
*/
protected function onError($job, \Exception $exception = null)
{
Console::error("Job ID#{$job['id']}: {$exception->getMessage()}");
}
示例7: runTasks
protected function runTasks()
{
foreach ($this->_tasks as $k => $id) {
Console::output(sprintf('Running task "%s" (%d/%d)', $id, $k + 1, count($this->_tasks)));
$result = $this->_container->get("tasks.{$id}")->run($this->_container, $this);
if ($result === false) {
Console::error(sprintf('Task "%s" failed.', $id));
return false;
}
}
return true;
}