本文整理匯總了PHP中Symfony\Component\Console\Output\OutputInterface::getErrorOutput方法的典型用法代碼示例。如果您正苦於以下問題:PHP OutputInterface::getErrorOutput方法的具體用法?PHP OutputInterface::getErrorOutput怎麽用?PHP OutputInterface::getErrorOutput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Output\OutputInterface
的用法示例。
在下文中一共展示了OutputInterface::getErrorOutput方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $stdout)
{
// capture error output
$stderr = $stdout instanceof ConsoleOutputInterface ? $stdout->getErrorOutput() : $stdout;
if ($input->getOption('watch')) {
$stderr->writeln('<error>The --watch option is deprecated. Please use the ' . 'assetic:watch command instead.</error>');
// build assetic:watch arguments
$arguments = array('command' => 'assetic:watch', 'write_to' => $this->basePath, '--period' => $input->getOption('period'), '--env' => $input->getOption('env'));
if ($input->getOption('no-debug')) {
$arguments['--no-debug'] = true;
}
if ($input->getOption('force')) {
$arguments['--force'] = true;
}
$command = $this->getApplication()->find('assetic:watch');
return $command->run(new ArrayInput($arguments), $stdout);
}
// print the header
$stdout->writeln(sprintf('Dumping all <comment>%s</comment> assets.', $input->getOption('env')));
$stdout->writeln(sprintf('Debug mode is <comment>%s</comment>.', $this->am->isDebug() ? 'on' : 'off'));
$stdout->writeln('');
if ($this->spork) {
$batch = $this->spork->createBatchJob($this->am->getNames(), new ChunkStrategy($input->getOption('forks')));
$self = $this;
$batch->execute(function ($name) use($self, $stdout) {
$self->dumpAsset($name, $stdout);
});
} else {
foreach ($this->am->getNames() as $name) {
$this->dumpAsset($name, $stdout);
}
}
}
示例2: getErrorOutput
/**
* @return OutputInterface
*/
private function getErrorOutput()
{
if ($this->output instanceof ConsoleOutputInterface) {
return $this->output->getErrorOutput();
}
return $this->output;
}
示例3: notifyFile
protected function notifyFile(SourceFileInfo $file)
{
$output = $this->output instanceof ConsoleOutputInterface ? $this->output->getErrorOutput() : $this->output;
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
$output->writeln("<info>Scanning {$file->getRelativePathname()}</info>");
}
}
示例4: log
/**
*
* {@inheritdoc}
*
*/
public function log($level, $message, array $context = array())
{
if (!isset($this->verbosityLevelMap[$level])) {
throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
}
// Write to the error output if necessary and available
if ($this->formatLevelMap[$level] === self::ERROR && $this->output instanceof ConsoleOutputInterface) {
$output = $this->output->getErrorOutput();
} else {
$output = $this->output;
}
if ($output->getVerbosity() >= $this->verbosityLevelMap[$level]) {
$output->writeln(sprintf('<%1$s>[%2$s] %3$s</%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)));
}
}
示例5: createProgressBar
/**
* @param int $count
* @param int $minVerbosity
*
* @return ProgressBar
*/
public function createProgressBar($count, $minVerbosity = OutputInterface::VERBOSITY_NORMAL)
{
$stream = new NullOutput();
if ($this->applicationInput->hasOption('progress') && $this->applicationInput->getOption('progress')) {
if ($this->applicationOutput instanceof ConsoleOutput) {
if ($this->applicationOutput->getVerbosity() >= $minVerbosity) {
$stream = $this->applicationOutput->getErrorOutput();
}
}
}
$progress = new ProgressBar($stream, $count);
// add an additional space, in case logging is also enabled
$progress->setFormat($progress->getFormatDefinition('normal') . ' ');
$progress->start();
return $progress;
}
示例6: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$error = $output->getErrorOutput();
$path = $input->getArgument("path");
$includeRoot = $input->getOption("include-root");
if (!\file_exists($path)) {
throw new \Exception("File {$path} doesn't exist");
}
try {
list($inform, $format) = \detectCertFormat($path);
$cert = \parseFormattedCert(\readCertificate($path, $inform, $format));
} catch (\Exception $e) {
$err = implode("\n", $e->output);
throw new \Exception("Unable to load certificate: {$err}");
}
// perform some basic checks
if (\isExpired($cert)) {
$error->writeln("Certificate has expired");
}
if (\areCertsLinked($cert, $cert)) {
throw new \Exception("Self-signed or CA cert");
}
// this can fail with an exception
$out = \buildChain($cert, $path, $includeRoot);
$output->write($out);
}
示例7: initialize
/**
* @inheritdoc
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->stdOut = $output;
$this->stdErr = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
$this->stdIn = $input;
self::$interactive = $input->isInteractive();
}
示例8: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
# If possible log to stderr because stdout receives the dot file
$logger = new SymfonyConsoleOutput($output instanceof ConsoleOutput ? $output->getErrorOutput() : $output);
$project = new Project($logger);
if ($input->getOption('quiet')) {
$logger->setReportingLevel(Logger::ERROR);
} else {
if ($input->getOption('verbose')) {
$logger->setReportingLevel(Logger::INFO);
}
}
SourceHandler::addSourcesToProject($input, $project);
# Necessary setup to generate the objectGraph
$project->addAnalyzer(new Parser(new \PhpParser\Parser(new Lexer())));
$project->addAnalyzer(new NameResolver());
$project->addAnalyzer($objectGraph = new ObjectGraph());
$project->analyze();
$graphviz = new GraphvizConverter();
$graphviz->setGraph($objectGraph);
# Console configuration
$graphviz->setNamespaceWhitelist($input->getOption('namespaces'));
$graphviz->setShowNamespace($input->getOption('show-namespace'));
$graphviz->setShowOnlyConnected($input->getOption('show-only-connected'));
$graphviz->setClusterByNamespace($input->getOption('cluster-namespaces'));
$graphviz->setNestClusters($input->getOption('nest-clusters'));
$output->write($graphviz->generate());
}
示例9: getOutput
/**
* {@inheritdoc}
*/
public function getOutput($level = LogLevel::NOTICE)
{
$output = $this->output;
if ($this->output instanceof ConsoleOutputInterface && in_array($level, array(LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, LogLevel::ERROR))) {
$output = $this->output->getErrorOutput();
}
return $output;
}
示例10: error_log
private function error_log($errorString)
{
if ($this->output instanceof ConsoleOutputInterface) {
$this->output->getErrorOutput()->writeln($errorString);
} else {
error_log($errorString);
}
}
示例11: write
/**
* {@inheritdoc}
*/
protected function write(array $record)
{
if ($record['level'] >= Logger::ERROR && $this->output instanceof ConsoleOutputInterface) {
$this->output->getErrorOutput()->write((string) $record['formatted']);
} else {
$this->output->write((string) $record['formatted']);
}
}
示例12: doWrite
/**
* @param array $messages
* @param bool $newline
* @param bool $stderr
*/
private function doWrite($messages, $newline, $stderr)
{
if (true === $stderr && $this->output instanceof ConsoleOutputInterface) {
$this->output->getErrorOutput()->write($messages, $newline);
return;
}
$this->output->write($messages, $newline);
}
示例13: initialize
/**
* @inheritdoc
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->stdOut = $output;
$this->stdErr = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
$this->stdIn = $input;
self::$interactive = $input->isInteractive();
// Check if this command requires a project to be defined in order to run.
$this->checkProjectRequired();
}
示例14: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$stderr = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
include_once $input->getArgument('input');
$config = array();
// 1. One-to-one maps
foreach ($this->option_map as $old => $new) {
if (defined($old)) {
$config[$new] = constant($old);
}
}
// 2. Special processing
if (defined('SIMPLEID_CLEAN_URL') && !constant('SIMPLEID_CLEAN_URL')) {
$stderr->writeln('<error>SIMPLEID_CLEAN_URL is set to false. This is not supported by SimpleID 2.</error>');
}
if (defined('SIMPLEID_STORE') && constant('SIMPLEID_STORE') != 'filesystem') {
$stderr->writeln('<error>Warning: Custom SIMPLEID_STORE. This will need to be migrated manually.</error>');
}
if (defined('SIMPLEID_CACHE_DIR')) {
$config['cache'] = 'folder=' . constant('SIMPLEID_CACHE_DIR');
}
if (defined('SIMPLEID_LOGLEVEL')) {
$config['log_level'] = $this->log_level_map[constant('SIMPLEID_LOGLEVEL')];
}
// 3. Add required configuration
$config = array_merge($config, $this->additional_config);
// 4. Results.
$results = <<<_END_HEADER_
<?php
#
# SimpleID configuration file.
#
# ** Generated by SimpleIDTool **
#
# ** Review this file against config.php.dist and make additional manual
# changes **
#
# By default, the SimpleID configuration is formatted as YAML. However
# you can insert PHP code after the YAML section for further configuration.
#
{$config} = Spyc::YAMLLoadString(<<<_END_YAML_
_END_HEADER_;
$results .= Spyc::YAMLDump($config, 4, false, true);
$results .= <<<_END_FOOTER_
_END_YAML_
);
?>
_END_FOOTER_;
if ($input->getArgument('output')) {
file_put_contents($input->getArgument('output', $results));
} else {
$output->writeln($results);
}
}
示例15: initialize
/**
* @inheritdoc
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->stdOut = $output;
$this->stdErr = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
$this->stdIn = $input;
self::$interactive = $input->isInteractive();
if (empty(Config::get())) {
$this->getApplication()->find('init')->run($input, $output);
exit(1);
}
}