本文整理匯總了PHP中Symfony\Component\Console\Output\ConsoleOutput::setFormatter方法的典型用法代碼示例。如果您正苦於以下問題:PHP ConsoleOutput::setFormatter方法的具體用法?PHP ConsoleOutput::setFormatter怎麽用?PHP ConsoleOutput::setFormatter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Output\ConsoleOutput
的用法示例。
在下文中一共展示了ConsoleOutput::setFormatter方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
/**
* Method overridden to add output customizations and use the output object
* for application logging.
*/
public function run(InputInterface $input = null, OutputInterface $output = null)
{
if (null === $output) {
$output = new ConsoleOutput();
$output->setFormatter(new OutputFormatter($output->isDecorated()));
}
return parent::run($input, $output);
}
示例2: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$bundlezip = $input->getOption('zip-file');
if (!$bundlezip) {
$helper = $this->getHelper('question');
$question = new Question('<info>Please enter the name of the zip file:</info> <comment>[webflow]</comment> ', 'webflow');
$bundlezip = $helper->ask($input, $output, $question);
}
$withZip = $bundlezip . ".zip";
// Theme Name
$theme = $input->getOption('theme-name');
if (!$theme) {
$helper = $this->getHelper('question');
$question = new Question('<info>Please enter theme name:</info> <comment>[webflow]</comment> ', 'webflow');
$theme = $helper->ask($input, $output, $question);
}
// Theme Description
// $themeDesc = $input->getOption('theme-description');
// if(!$themeDesc){
// $helper = $this->getHelper('question');
// $question = new Question('<info>Please enter theme description:</info> <comment>[These is a webflow theme]</comment> ', 'These is a webflow theme');
// $themeDesc = $helper->ask($input, $output, $question);
// }
$themeDesc = 'These is a webflow theme';
$path = getcwd() . '/temp';
$zip = new ZipArchive();
if ($zip->open($withZip) === TRUE) {
$zip->extractTo($path);
$zip->close();
$output->writeln('<info>Starting Theme creation process</info>');
} else {
$output->writeln('<comment>Failed to open the archive!</comment>');
return false;
}
$directory = "{$path}/{$bundlezip}/";
$htmlfiles = glob($directory . "*.html");
$themeMachine = strtolower(str_replace(" ", "_", $theme));
$Root = getcwd() . '/themes';
$themeDir = "{$Root}/{$theme}";
$create = new ClutchCli();
$output = new ConsoleOutput();
$output->setFormatter(new OutputFormatter(true));
$rows = 8;
$progressBar = new ProgressBar($output, $rows);
$progressBar->setFormat(' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%');
$progressBar->setBarCharacter('<fg=magenta>=</>');
$progressBar->setProgressCharacter("🏃");
$progressBar->setOverwrite(true);
for ($i = 0; $i < $rows; $i++) {
$create->Components($themeDir, $theme, $htmlfiles, 'data-component', 'components');
$create->Components($themeDir, $theme, $htmlfiles, 'data-node', 'nodes');
$create->Components($themeDir, $theme, $htmlfiles, 'data-menu', 'menus');
$progressBar->advance(2);
$create->Directory($path, $Root, $themeDir, $theme, $bundlezip);
$progressBar->advance();
$vars = array('{{themeName}}' => $theme, '{{themeMachine}}' => $themeMachine, '{{themeDescription}}' => $themeDesc);
$progressBar->advance();
$create->ThemeTemplates($themeDir, $theme, $vars);
$progressBar->advance();
$create->deleteDirectory($path);
$progressBar->advance();
\Drupal::service('theme_handler')->rebuildThemeData();
$progressBar->advance();
\Drupal::service('theme_handler')->reset();
\Drupal::service('theme_handler')->refreshInfo();
\Drupal::service('theme_handler')->listInfo();
// $this->getChain()->addCommand('cache:rebuild', ['cache' => 'all']);
// $this->getChain()->addCommand('clutch:sync', ['theme' => $theme]);
$progressBar->advance();
$output->writeln('<comment>' . "\r\n" . 'Your theme ' . $theme . ' is now created.</comment>');
return true;
}
$progressBar->finish();
}
示例3: Application
<?php
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Igorw\Fab\FabOutputFormatterStyle;
require 'vendor/autoload.php';
$app = new Application();
$app->register('foo')->setDefinition(array(new InputArgument('bar', InputArgument::REQUIRED, 'Bar')))->setDescription('Does foo with bar')->setCode(function (InputInterface $input, OutputInterface $output) {
$bar = $input->getArgument('bar');
$output->writeln(sprintf('This is the foo for <info>%s</info>', $bar));
$output->writeln(sprintf('<comment>%s</comment>', sha1($bar)));
});
$input = new ArgvInput();
$output = new ConsoleOutput();
$output->setFormatter(new OutputFormatter(true, ['info' => new FabOutputFormatterStyle(), 'comment' => new FabOutputFormatterStyle()]));
$app->run($input, $output);