本文整理汇总了PHP中Symfony\Component\Console\Formatter\OutputFormatter::setStyle方法的典型用法代码示例。如果您正苦于以下问题:PHP OutputFormatter::setStyle方法的具体用法?PHP OutputFormatter::setStyle怎么用?PHP OutputFormatter::setStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Formatter\OutputFormatter
的用法示例。
在下文中一共展示了OutputFormatter::setStyle方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Creates the formatter.
*
* @param StyleSet $styleSet The style set to use.
*/
public function __construct(StyleSet $styleSet = null)
{
$this->innerFormatter = new OutputFormatter(false);
if (!$styleSet) {
$styleSet = new DefaultStyleSet();
}
foreach ($styleSet->toArray() as $tag => $style) {
$this->innerFormatter->setStyle($tag, StyleConverter::convert($style));
}
}
示例2: testRedefineStyle
public function testRedefineStyle()
{
$formatter = new OutputFormatter(true);
$style = new OutputFormatterStyle('blue', 'white');
$formatter->setStyle('info', $style);
$this->assertEquals("[34;47msome custom msg[39;49m", $formatter->format('<info>some custom msg</info>'));
}
示例3: testRedefineStyle
public function testRedefineStyle()
{
$formatter = new OutputFormatter(true);
$style = $this->getMockBuilder('Symfony\\Component\\Console\\Formatter\\OutputFormatterStyleInterface')->getMock();
$formatter->setStyle('info', $style);
$style->expects($this->once())->method('apply')->will($this->returnValue('[STYLE_BEG]some custom msg[STYLE_END]'));
$this->assertEquals("[STYLE_BEG]some custom msg[STYLE_END]", $formatter->format('<info>some custom msg</info>'));
}
示例4: __construct
public function __construct($config)
{
$this->config = array_merge($this->config, $config);
// enable interactive output mode for CLI
$this->isInteractive = $this->config['interactive'] && isset($_SERVER['TERM']) && php_sapi_name() == 'cli' && $_SERVER['TERM'] != 'linux';
$formatter = new OutputFormatter($this->config['colors']);
$formatter->setStyle('default', new OutputFormatterStyle());
$formatter->setStyle('bold', new OutputFormatterStyle(null, null, ['bold']));
$formatter->setStyle('focus', new OutputFormatterStyle('magenta', null, ['bold']));
$formatter->setStyle('ok', new OutputFormatterStyle('green', null, ['bold']));
$formatter->setStyle('error', new OutputFormatterStyle('white', 'red', ['bold']));
$formatter->setStyle('fail', new OutputFormatterStyle('red', null, ['bold']));
$formatter->setStyle('pending', new OutputFormatterStyle('yellow', null, ['bold']));
$formatter->setStyle('debug', new OutputFormatterStyle('cyan'));
$formatter->setStyle('comment', new OutputFormatterStyle('yellow'));
$formatter->setStyle('info', new OutputFormatterStyle('green'));
$this->formatHelper = new FormatterHelper();
parent::__construct($this->config['verbosity'], $this->config['colors'], $formatter);
}
示例5: run
/**
* Override run method to internationalize error message.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return int Return code
*/
public function run(InputInterface $input, OutputInterface $output)
{
// Set extra colors
// The most problem is $output->getFormatter() don't work.
// So create new formatter to add extra color.
$formatter = new OutputFormatter($output->isDecorated());
$formatter->setStyle('red', new OutputFormatterStyle('red', 'black'));
$formatter->setStyle('green', new OutputFormatterStyle('green', 'black'));
$formatter->setStyle('yellow', new OutputFormatterStyle('yellow', 'black'));
$formatter->setStyle('blue', new OutputFormatterStyle('blue', 'black'));
$formatter->setStyle('magenta', new OutputFormatterStyle('magenta', 'black'));
$formatter->setStyle('yellow-blue', new OutputFormatterStyle('yellow', 'blue'));
$output->setFormatter($formatter);
\App::setLocale(\Config::get('syncle::MessageLang'));
try {
$result = parent::run($input, $output);
} catch (\RuntimeException $e) {
// All error messages were hard coded in
// Symfony/Component/Console/Input/Input.php
if ($e->getMessage() == 'Not enough arguments.') {
$this->error(\Lang::get('syncle::BaseCommand.ArgumentNotEnough'));
} elseif ($e->getMessage() == 'Too many arguments.') {
$this->error(\Lang::get('syncle::BaseCommand.TooManyArgument'));
} elseif (preg_match('/The "(.+)" option does not exist./', $e->getMessage(), $matches)) {
$this->error(\Lang::get('syncle::BaseCommand.OptionNotExist', array('option' => $matches[1])));
} else {
$this->error($e->getMessage());
}
$result = 1;
}
return $result;
}
示例6: getOutputFormatter
/**
* Initialize and get console output formatter
*
* @return OutputFormatter
*/
protected function getOutputFormatter()
{
if (null === $this->outputFormatter) {
$formatter = new OutputFormatter(true);
$formatter->setStyle(LogLevel::EMERGENCY, new OutputFormatterStyle('white', 'red'));
$formatter->setStyle(LogLevel::ALERT, new OutputFormatterStyle('white', 'red'));
$formatter->setStyle(LogLevel::CRITICAL, new OutputFormatterStyle('red'));
$formatter->setStyle(LogLevel::ERROR, new OutputFormatterStyle('red'));
$formatter->setStyle(LogLevel::WARNING, new OutputFormatterStyle('yellow'));
$formatter->setStyle(LogLevel::NOTICE, new OutputFormatterStyle());
$formatter->setStyle(LogLevel::INFO, new OutputFormatterStyle());
$formatter->setStyle(LogLevel::DEBUG, new OutputFormatterStyle('cyan'));
$this->outputFormatter = $formatter;
}
return $this->outputFormatter;
}
示例7: OutputFormatter
function __construct($config)
{
$this->config = array_merge($this->config, $config);
$formatter = new OutputFormatter($this->config['colors']);
$formatter->setStyle('bold', new OutputFormatterStyle(null, null, array('bold')));
$formatter->setStyle('focus', new OutputFormatterStyle('magenta', null, array('bold')));
$formatter->setStyle('ok', new OutputFormatterStyle('white', 'magenta'));
$formatter->setStyle('error', new OutputFormatterStyle('white', 'red'));
$formatter->setStyle('debug', new OutputFormatterStyle('cyan'));
$formatter->setStyle('info', new OutputFormatterStyle('yellow'));
$this->formatHelper = new FormatterHelper();
parent::__construct($this->config['verbosity'], $this->config['colors'], $formatter);
}
示例8: run
public function run(InputInterface $input, OutputInterface $output)
{
// Set extra colors.
// The most problem is $output->getFormatter() don't work...
// So create new formatter to add extra color.
$formatter = new OutputFormatter($output->isDecorated());
$formatter->setStyle('red', new OutputFormatterStyle('red', 'black'));
$formatter->setStyle('green', new OutputFormatterStyle('green', 'black'));
$formatter->setStyle('yellow', new OutputFormatterStyle('yellow', 'black'));
$formatter->setStyle('blue', new OutputFormatterStyle('blue', 'black'));
$formatter->setStyle('magenta', new OutputFormatterStyle('magenta', 'black'));
$formatter->setStyle('yellow-blue', new OutputFormatterStyle('yellow', 'blue'));
$output->setFormatter($formatter);
return parent::run($input, $output);
}
示例9: configureFormatter
/**
* Configure the output formatter
*/
private function configureFormatter(OutputFormatter $formatter)
{
$style = new OutputFormatterStyle('yellow', null, array('bold'));
$formatter->setStyle('path', $style);
$style = new OutputFormatterStyle('green');
$formatter->setStyle('localname', $style);
$style = new OutputFormatterStyle(null, null, array('bold'));
$formatter->setStyle('node', $style);
$style = new OutputFormatterStyle('blue', null, array('bold'));
$formatter->setStyle('templatenode', $style);
$style = new OutputFormatterStyle('blue', null, array());
$formatter->setStyle('templateproperty', $style);
$style = new OutputFormatterStyle(null, null, array());
$formatter->setStyle('property', $style);
$style = new OutputFormatterStyle('magenta', null, array('bold'));
$formatter->setStyle('node-type', $style);
$style = new OutputFormatterStyle('magenta', null, array());
$formatter->setStyle('property-type', $style);
$style = new OutputFormatterStyle(null, null, array());
$formatter->setStyle('property-value', $style);
$style = new OutputFormatterStyle(null, 'red', array());
$formatter->setStyle('exception', $style);
}