本文整理匯總了PHP中Symfony\Component\Console\Output\OutputInterface::getFormatter方法的典型用法代碼示例。如果您正苦於以下問題:PHP OutputInterface::getFormatter方法的具體用法?PHP OutputInterface::getFormatter怎麽用?PHP OutputInterface::getFormatter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Output\OutputInterface
的用法示例。
在下文中一共展示了OutputInterface::getFormatter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->useIsoStandard = $input->getOption('sunday') == true ? false : true;
$output->getFormatter()->setStyle('lvl0', new ColorOutputFormatterStyle('lvl0'));
$output->getFormatter()->setStyle('lvl1', new ColorOutputFormatterStyle('lvl1'));
$output->getFormatter()->setStyle('lvl2', new ColorOutputFormatterStyle('lvl2'));
$output->getFormatter()->setStyle('lvl3', new ColorOutputFormatterStyle('lvl3'));
$output->getFormatter()->setStyle('lvl4', new ColorOutputFormatterStyle('lvl4'));
$matrix = $this->getMatrix();
$counts = $this->getCommitCounts($matrix);
$q1 = $counts[intval(count($counts) / 4)];
$q2 = $counts[intval(count($counts) / 2)];
$q3 = $counts[intval(count($counts) * 3 / 4)];
$output->writeln("╔" . str_repeat("═", count($matrix) / 7 * 2 + 5) . "╗");
$output->writeln("║ " . $this->getMonthsHeader($matrix) . " ║");
for ($weekday = 1; $weekday <= 7; $weekday++) {
$weekdayModulus = $weekday == 7 ? 0 : $weekday;
$days = [];
foreach ($matrix as $dayNumber => $day) {
if ($dayNumber % 7 == $weekdayModulus) {
$days[] = $this->getBlock($day['commits'], $q1, $q2, $q3);
}
}
$output->writeln("║ " . $this->getWeekdayName($weekday - 1) . " " . implode(' ', $days) . " ║");
}
$output->writeln("║" . str_repeat(" ", count($matrix) / 7 * 2 + 5) . "║");
$output->writeln("║" . $this->getLegend(count($matrix) / 7 * 2 + 5) . "║");
$output->writeln("╚" . str_repeat("═", count($matrix) / 7 * 2 + 5) . "╝");
}
示例2: run
/**
* Executes the application.
*
* Available options:
*
* * interactive: Sets the input interactive flag
* * decorated: Sets the output decorated flag
* * verbosity: Sets the output verbosity flag
* * capture_stderr_separately: Make output of stdOut and stdErr separately available
*
* @param array $input An array of arguments and options
* @param array $options An array of options
*
* @return int The command exit code
*/
public function run(array $input, $options = array())
{
$this->input = new ArrayInput($input);
if (isset($options['interactive'])) {
$this->input->setInteractive($options['interactive']);
}
$this->captureStreamsIndependently = array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
if (!$this->captureStreamsIndependently) {
$this->output = new StreamOutput(fopen('php://memory', 'w', false));
if (isset($options['decorated'])) {
$this->output->setDecorated($options['decorated']);
}
if (isset($options['verbosity'])) {
$this->output->setVerbosity($options['verbosity']);
}
} else {
$this->output = new ConsoleOutput(isset($options['verbosity']) ? $options['verbosity'] : ConsoleOutput::VERBOSITY_NORMAL, isset($options['decorated']) ? $options['decorated'] : null);
$errorOutput = new StreamOutput(fopen('php://memory', 'w', false));
$errorOutput->setFormatter($this->output->getFormatter());
$errorOutput->setVerbosity($this->output->getVerbosity());
$errorOutput->setDecorated($this->output->isDecorated());
$reflectedOutput = new \ReflectionObject($this->output);
$strErrProperty = $reflectedOutput->getProperty('stderr');
$strErrProperty->setAccessible(true);
$strErrProperty->setValue($this->output, $errorOutput);
$reflectedParent = $reflectedOutput->getParentClass();
$streamProperty = $reflectedParent->getProperty('stream');
$streamProperty->setAccessible(true);
$streamProperty->setValue($this->output, fopen('php://memory', 'w', false));
}
return $this->statusCode = $this->application->run($this->input, $this->output);
}
示例3: addStyles
public function addStyles(OutputInterface $output)
{
$style = new OutputFormatterStyle('white', 'green', ['bold']);
$output->getFormatter()->setStyle('notice', $style);
$style = new OutputFormatterStyle(null, null, ['bold']);
$output->getFormatter()->setStyle('bold', $style);
}
示例4: outputFormatterEscape
protected function outputFormatterEscape($message)
{
if ($this->output) {
return $this->output->getFormatter()->escape($message);
}
return $message;
}
示例5: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->getFormatter()->setStyle('red', new OutputFormatterStyle('red'));
$output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan'));
$output->getFormatter()->setStyle('green', new OutputFormatterStyle('green'));
$output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta'));
$this->progress = new ProgressBar($output);
$this->progress->setFormat('Archiving <cyan>%current%</cyan> files [<green>%bar%</green>] %elapsed:6s% %memory:6s%');
$name = basename($this->source);
$dir = dirname($this->source);
$date = date('YmdHis', time());
$filename = $name . '-' . $date . '.zip';
$destination = $input->getArgument('destination') ? $input->getArgument('destination') : ROOT_DIR;
$destination = rtrim($destination, DS) . DS . $filename;
$output->writeln('');
$output->writeln('Creating new Backup "' . $destination . '"');
$this->progress->start();
$zip = new \ZipArchive();
$zip->open($destination, \ZipArchive::CREATE);
$zip->addEmptyDir($name);
$this->folderToZip($this->source, $zip, strlen($dir . DS), $this->progress);
$zip->close();
$this->progress->finish();
$output->writeln('');
$output->writeln('');
}
示例6: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->destination = $input->getArgument('destination');
$this->input = $input;
$this->output = $output;
// Create a red output option
$this->output->getFormatter()->setStyle('red', new OutputFormatterStyle('red'));
$this->output->getFormatter()->setStyle('cyan', new OutputFormatterStyle('cyan'));
$this->output->getFormatter()->setStyle('magenta', new OutputFormatterStyle('magenta'));
// Symlink the Core Stuff
if ($input->getOption('symlink')) {
// Create Some core stuff if it doesn't exist
$this->createDirectories();
// Loop through the symlink mappings and create the symlinks
$this->symlink();
// Copy the Core STuff
} else {
// Create Some core stuff if it doesn't exist
$this->createDirectories();
// Loop through the symlink mappings and copy what otherwise would be symlinks
$this->copy();
}
$this->pages();
$this->initFiles();
$this->perms();
}
示例7: execute
/**
* execute api command
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$aData = array();
// set colors and formats
$oErrStyle = new OutputFormatterStyle('red', null, array('bold'));
$oOkStyle = new OutputFormatterStyle('green', null, array('bold'));
$oLogoStyle = new OutputFormatterStyle('cyan', null);
$output->getFormatter()->setStyle('err', $oErrStyle);
$output->getFormatter()->setStyle('ok', $oOkStyle);
$output->getFormatter()->setStyle('sw', $oLogoStyle);
// print logo
$this->_printLogo($output);
// Get active remote apps
$aRemoteApps = RemoteAppQuery::create()->findByActivated(true);
/** @var RemoteApp $oRemoteApp */
$iCnt = 0;
foreach ($aRemoteApps as $oRemoteApp) {
// get cron string
$aData[] = array($oRemoteApp->getId(), $oRemoteApp->getName(), $oRemoteApp->getLastRun()->format("d.m.Y H:i:s"));
$iCnt++;
}
// get tablehelper for cli
$oTable = $this->getHelper('table');
$oTable->setHeaders(array('ID', 'Title', 'Lastrun'))->setRows($aData);
$oTable->render($output);
// green text
$output->writeln("\n<fg=white;options=bold> " . $iCnt . " Job(s) found</fg=white;options=bold>\n");
}
示例8: initStyle
private function initStyle(OutputInterface $output)
{
$style = new OutputFormatterStyle('black', 'black');
$output->getFormatter()->setStyle('blackc', $style);
$style = new OutputFormatterStyle('white', 'white');
$output->getFormatter()->setStyle('whitec', $style);
}
示例9: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if (info()->installMode()) {
die('Opis Colibri is not installed' . PHP_EOL);
}
$output->getFormatter()->setStyle('b-error', new OutputFormatterStyle('white', 'red', array('bold')));
$output->getFormatter()->setStyle('warning', new OutputFormatterStyle('yellow'));
$output->getFormatter()->setStyle('b-warning', new OutputFormatterStyle('yellow', null, array('bold')));
$output->getFormatter()->setStyle('b-info', new OutputFormatterStyle('green', null, array('bold')));
$modules = $input->getArgument('module');
foreach ($modules as $moduleName) {
$module = module($moduleName);
if (!$module->exists()) {
$output->writeln('<error>Module <b-error>' . $moduleName . '</b-error> doesn\'t exist.</error>');
continue;
}
if (!$module->isInstalled()) {
$output->writeln('<warning>Module <b-warning>' . $moduleName . '</b-warning> is already uninstaled.</warning>');
continue;
}
if ($module->isHidden()) {
$output->writeln('<error>Module <b-error>' . $moduleName . '</b-error> is hidden and can\'t be uninstalled.');
continue;
}
if ($module->uninstall()) {
$output->writeln('<info>Module <b-info>' . $moduleName . '</b-info> was uninstalled.</info>');
} else {
$output->writeln('<error>Module <b-error>' . $moduleName . '</b-error> could not be uninstalled.</error>');
}
}
}
示例10: __construct
/**
* Initializes printer.
*
* @param OutputInterface $output
* @param TranslatorInterface $translator
*/
public function __construct(OutputInterface $output, TranslatorInterface $translator)
{
$this->output = $output;
$this->translator = $translator;
$output->getFormatter()->setStyle('snippet_keyword', new OutputFormatterStyle(null, null, array('bold')));
$output->getFormatter()->setStyle('snippet_undefined', new OutputFormatterStyle('yellow'));
}
示例11: __construct
/**
* Constructor
*
* @param OutputInterface $output
*/
public function __construct(OutputInterface $output)
{
$this->console = $output;
$outputFormatter = $this->console->getFormatter();
$outputFormatter->setStyle('detail', new OutputFormatterStyle('blue'));
$outputFormatter->setStyle('metadata', new OutputFormatterStyle('cyan'));
}
示例12: initialize
/**
* @see parent::initialize()
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
$style = new OutputFormatterStyle('blue', null, array('bold'));
$output->getFormatter()->setStyle('b', $style);
$style = new OutputFormatterStyle(null, 'red', array('bold'));
$output->getFormatter()->setStyle('error', $style);
}
示例13: describeRule
/**
* Display rule description
*
* @param RuleInterface $rule
* @param OutputInterface $output
* @return void
*/
public function describeRule(RuleInterface $rule, OutputInterface $output)
{
$output->getFormatter()->setStyle('strong', new OutputFormatterStyle(null, null, ['bold', 'reverse']));
$output->getFormatter()->setStyle('em', new OutputFormatterStyle('yellow', null, ['bold']));
$output->getFormatter()->setStyle('code', new OutputFormatterStyle('green'));
$output->writeln("<strong>{$rule->getName()}</strong>\n");
$output->writeln("{$rule->getLongDescription()}\n");
}
示例14: __construct
/**
* @param InputInterface $input
* @param OutputInterface $output
* @param HelperSet $helperSet
*/
public function __construct(InputInterface $input, OutputInterface $output, HelperSet $helperSet)
{
$this->input = $input;
$this->output = $output;
$this->helperSet = $helperSet;
$this->output->getFormatter()->setStyle('header', new OutputFormatterStyle('yellow', null, array('bold')));
$this->output->getFormatter()->setStyle('question', new OutputFormatterStyle('yellow', null, array('bold')));
}
示例15: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $output;
// Configure extra output formats
$this->output->getFormatter()->setStyle('bold', new OutputFormatterStyle('blue'));
$this->fire();
}