本文整理匯總了PHP中Symfony\Component\Console\Output\OutputInterface::setDecorated方法的典型用法代碼示例。如果您正苦於以下問題:PHP OutputInterface::setDecorated方法的具體用法?PHP OutputInterface::setDecorated怎麽用?PHP OutputInterface::setDecorated使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Output\OutputInterface
的用法示例。
在下文中一共展示了OutputInterface::setDecorated方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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);
}
示例2: setUp
protected function setUp()
{
$config = new Config($this->getConfigArray());
$this->input = new ArrayInput([]);
$this->output = new StreamOutput(fopen('php://memory', 'a', false));
$this->output->setDecorated(false);
$this->manager = new Manager($config, $this->input, $this->output);
}
示例3: configureIO
protected function configureIO(InputInterface $input, OutputInterface $output)
{
if (true === $input->hasParameterOption(array('--colors'))) {
$output->setDecorated(true);
} elseif (true === $input->hasParameterOption(array('--no-colors'))) {
$output->setDecorated(false);
}
parent::configureIO($input, $output);
}
示例4: doRun
/**
* Runs the current application.
*
* @param InputInterface $input An Input instance
* @param OutputInterface $output An Output instance
*
* @return integer 0 if everything went fine, or an error code
*/
public function doRun(InputInterface $input, OutputInterface $output)
{
$output->writeLn($this->getHeader());
$name = $this->getCommandName($input);
if (true === $input->hasParameterOption(array('--shell', '-s'))) {
$shell = new Shell($this);
$shell->run();
return 0;
}
if (true === $input->hasParameterOption(array('--ansi'))) {
$output->setDecorated(true);
} elseif (true === $input->hasParameterOption(array('--no-ansi'))) {
$output->setDecorated(false);
}
if (true === $input->hasParameterOption(array('--help', '-h'))) {
if (!$name) {
$name = 'help';
$input = new ArrayInput(array('command' => 'help'));
} else {
$this->wantHelps = true;
}
}
if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
$input->setInteractive(false);
}
if (function_exists('posix_isatty') && $this->getHelperSet()->has('dialog')) {
$inputStream = $this->getHelperSet()->get('dialog')->getInputStream();
if (!posix_isatty($inputStream)) {
$input->setInteractive(false);
}
}
if (true === $input->hasParameterOption(array('--quiet', '-q'))) {
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
} elseif (true === $input->hasParameterOption(array('--verbose', '-v'))) {
$output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
}
if (true === $input->hasParameterOption(array('--version', '-V'))) {
$output->writeln($this->getLongVersion());
return 0;
}
if (!$name) {
$name = 'list';
$input = new ArrayInput(array('command' => 'list'));
}
// the command name MUST be the first element of the input
$command = $this->find($name);
$this->runningCommand = $command;
$statusCode = $command->run($input, $output);
$this->runningCommand = null;
# write Footer
$output->writeLn($this->getFooter());
return is_numeric($statusCode) ? $statusCode : 0;
}
示例5: decorateOutput
private function decorateOutput()
{
if ($this->output === null) {
return;
}
$this->output->setDecorated(true);
}
示例6: execute
/**
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->setDecorated(true);
$style = new OutputFormatterStyle('red');
$output->getFormatter()->setStyle('stacktrace', $style);
$this->executeGenerateBootstrap($input, $output);
}
示例7: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->setDecorated(true);
$this->appState->setAreaCode('catalog');
$connection = $this->attributeResource->getConnection();
$attributeTables = $this->getAttributeTables();
$progress = new \Symfony\Component\Console\Helper\ProgressBar($output, count($attributeTables));
$progress->setFormat('<comment>%message%</comment> %current%/%max% [%bar%] %percent:3s%% %elapsed%');
$this->attributeResource->beginTransaction();
try {
// Find and remove unused attributes
foreach ($attributeTables as $attributeTable) {
$progress->setMessage($attributeTable . ' ');
$affectedIds = $this->getAffectedAttributeIds($connection, $attributeTable);
if (count($affectedIds) > 0) {
$connection->delete($attributeTable, ['value_id in (?)' => $affectedIds]);
}
$progress->advance();
}
$this->attributeResource->commit();
$output->writeln("");
$output->writeln("<info>Unused product attributes successfully cleaned up:</info>");
$output->writeln("<comment> " . implode("\n ", $attributeTables) . "</comment>");
} catch (\Exception $exception) {
$this->attributeResource->rollBack();
$output->writeln("");
$output->writeln("<error>{$exception->getMessage()}</error>");
}
}
示例8: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->setDecorated(true);
$table = new Table($output);
$table->setHeaders(['endpoint', 'method', 'controller', 'context', 'default_context']);
$endpointOption = $input->getOption('endpoint');
$allRoutes = $this->getRoutes();
/** @var Route[][] $sortedRoutes */
$sortedRoutes = [];
foreach ($allRoutes as $endpoint => $routes) {
foreach ($routes as $route) {
$sortedRoutes[$endpoint][$route->getMethod()] = $route;
}
ksort($sortedRoutes[$endpoint]);
}
foreach ($sortedRoutes as $endpoint => $routes) {
if (count($endpointOption) !== 0 && !in_array($endpoint, $endpointOption, true)) {
continue;
}
foreach ($routes as $route) {
$table->addRow([$endpoint, $route->getMethod(), $route->getController(), implode(',', $route->getContext()), $route->includeDefaultContext() ? 'true' : 'false']);
}
}
$table->render();
}
示例9: setupOutput
protected function setupOutput()
{
$outputResource = $this->getLogsResource();
$this->output = new StreamOutput($outputResource);
$this->output->setDecorated(false);
$this->output->setVerbosity(true);
}
示例10: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->setDecorated(true);
$username = $input->getOption('username');
$password = $input->getOption('password');
$plugin = $input->getOption('plugin');
$lastUpdate = $input->getOption('lastupdate');
$resource = 'piwik-' . ($plugin ? 'plugin-' . strtolower($plugin) : 'base');
$transifexApi = new API($username, $password);
// remove all existing translation files in download path
$files = glob($this->getDownloadPath() . DIRECTORY_SEPARATOR . '*.json');
array_map('unlink', $files);
if (!$transifexApi->resourceExists($resource)) {
$output->writeln("Skipping resource {$resource} as it doesn't exist on Transifex");
return;
}
$output->writeln("Fetching translations from Transifex for resource {$resource}");
$availableLanguages = LanguagesManagerApi::getInstance()->getAvailableLanguageNames();
$languageCodes = array();
foreach ($availableLanguages as $languageInfo) {
$languageCodes[] = $languageInfo['code'];
}
$languageCodes = array_filter($languageCodes, function ($code) {
return !in_array($code, array('en', 'dev'));
});
try {
$languages = $transifexApi->getAvailableLanguageCodes();
if (!empty($plugin)) {
$languages = array_filter($languages, function ($language) {
return LanguagesManagerApi::getInstance()->isLanguageAvailable(str_replace('_', '-', strtolower($language)));
});
}
} catch (AuthenticationFailedException $e) {
$languages = $languageCodes;
}
/** @var ProgressBar $progress */
$progress = new ProgressBar($output, count($languages));
$progress->start();
$statistics = $transifexApi->getStatistics($resource);
foreach ($languages as $language) {
try {
// if we have modification date given from statistics api compare it with given last update time to ignore not update resources
if (LanguagesManagerApi::getInstance()->isLanguageAvailable(str_replace('_', '-', strtolower($language))) && isset($statistics->{$language})) {
$lastupdated = strtotime($statistics->{$language}->last_update);
if ($lastUpdate > $lastupdated) {
$progress->advance();
continue;
}
}
$translations = $transifexApi->getTranslations($resource, $language, true);
file_put_contents($this->getDownloadPath() . DIRECTORY_SEPARATOR . str_replace('_', '-', strtolower($language)) . '.json', $translations);
} catch (\Exception $e) {
$output->writeln("Error fetching language file {$language}: " . $e->getMessage());
}
$progress->advance();
}
$progress->finish();
$output->writeln('');
}
示例11: initialize
protected function initialize(InputInterface $input, OutputInterface $output)
{
// Because colors are coolest ...
$output->setDecorated(true);
// TODO: Violation of law of demeter.
// Since this is considered "framework layer" and has little churn...
// Probably okay.
$this->app = $this->getApplication()->getContainer();
}
示例12: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$connection = $this->getDatabaseConnection($input);
// If not explicitly set, disable ANSI which will break generated php.
if ($input->hasParameterOption(['--ansi']) !== TRUE) {
$output->setDecorated(FALSE);
}
$schema_tables = $input->getOption('schema-only');
$schema_tables = explode(',', $schema_tables);
$output->writeln($this->generateScript($connection, $schema_tables), OutputInterface::OUTPUT_RAW);
}
示例13: runJob
protected function runJob(CronJob $job, OutputInterface $output, EntityManager $em, $date = null)
{
$date = $date == null ? new \DateTime() : $date;
$output->setDecorated(true);
$output->writeln("<comment>Running " . $job->getCommand() . ": </comment>");
try {
$commandToRun = $this->getApplication()->get($job->getCommand());
} catch (InvalidArgumentException $ex) {
$output->writeln(" skipped (command no longer exists)");
$this->recordJobResult($em, $job, 0, "Command no longer exists", CronJobResult::SKIPPED);
// No need to reschedule non-existant commands
return;
}
$emptyInput = new ArgvInput();
$jobOutput = new MemoryWriter();
$jobStart = microtime(true);
try {
$returnCode = $commandToRun->execute($emptyInput, $jobOutput);
} catch (\Exception $ex) {
$returnCode = CronJobResult::FAILED;
$jobOutput->writeln("");
$jobOutput->writeln("Job execution failed with exception " . get_class($ex) . ":");
$jobOutput->writeln($ex->__toString());
}
$jobEnd = microtime(true);
// Clamp the result to accepted values
if ($returnCode < CronJobResult::RESULT_MIN || $returnCode > CronJobResult::RESULT_MAX) {
$returnCode = CronJobResult::FAILED;
}
// Output the result
$statusStr = "unknown";
if ($returnCode == CronJobResult::SKIPPED) {
$statusStr = "skipped";
} elseif ($returnCode == CronJobResult::SUCCEEDED) {
$statusStr = "succeeded";
} elseif ($returnCode == CronJobResult::FAILED) {
$statusStr = "failed";
}
$output->writeln($jobOutput->getOutput());
$durationStr = sprintf("%0.2f", $jobEnd - $jobStart);
$output->writeln("{$statusStr} in {$durationStr} seconds");
// Record the result
$this->recordJobResult($em, $job, $jobEnd - $jobStart, $jobOutput->getOutput(), $returnCode);
// And update the job with it's next scheduled time
$newTime = clone $date;
$output->writeln('New Time : ' . $newTime->format(DATE_ATOM));
$newTime = $newTime->add(new \DateInterval($job->getInterval()));
$output->writeln('New interval Time : ' . $newTime->format(DATE_ATOM));
$job->setNextRun($newTime);
}
示例14: execute
/**
* @see Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
try {
$this->getDocumentManager()->getSchemaManager()->ensureIndexes();
$output->setDecorated(true);
$cannedMessage = new CannedMessage();
$cannedMessage->setTitle($input->getArgument('title'));
$cannedMessage->setContent($input->getArgument('content'));
$this->getDocumentManager()->persist($cannedMessage);
$this->getDocumentManager()->flush(array('safe' => true));
$output->write("Pronto", true);
} catch (MongoCursorException $e) {
$output->write($e->getMessage(), true);
}
}
示例15: execute
/**
* {@inheritDoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$filesystem = $input->getArgument('filesystem');
$glob = $input->getArgument('glob');
$container = $this->getContainer();
$serviceId = sprintf('gaufrette.%s_filesystem', $filesystem);
if (!$container->has($serviceId)) {
throw new \RuntimeException(sprintf('There is no \'%s\' filesystem defined.', $filesystem));
}
$filesystem = $container->get($serviceId);
$keys = $filesystem->keys();
if (!empty($glob)) {
$glob = new Glob($glob);
$keys = $glob->filter($keys);
}
$count = count($keys);
$output->writeln(sprintf('Bellow %s the <info>%s key%s</info> that where found:', $count > 1 ? 'are' : 'is', $count, $count > 1 ? 's' : ''));
$output->setDecorated(true);
foreach ($keys as $key) {
$output->writeln(' - <info>' . $key . '</info>');
}
}