本文整理匯總了PHP中Symfony\Component\Console\Output\OutputInterface::page方法的典型用法代碼示例。如果您正苦於以下問題:PHP OutputInterface::page方法的具體用法?PHP OutputInterface::page怎麽用?PHP OutputInterface::page使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Output\OutputInterface
的用法示例。
在下文中一共展示了OutputInterface::page方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($this->command !== null) {
// help for an individual command
$output->page($this->command->asText());
$this->command = null;
} elseif ($name = $input->getArgument('command_name')) {
// help for an individual command
$output->page($this->getApplication()->get($name)->asText());
} else {
// list available commands
$commands = $this->getApplication()->all();
$table = $this->getTable($output);
foreach ($commands as $name => $command) {
if ($name !== $command->getName()) {
continue;
}
if ($command->getAliases()) {
$aliases = sprintf('<comment>Aliases:</comment> %s', implode(', ', $command->getAliases()));
} else {
$aliases = '';
}
$table->addRow(array(sprintf('<info>%s</info>', $name), $command->getDescription(), $aliases));
}
$output->startPaging();
if ($table instanceof TableHelper) {
$table->render($output);
} else {
$table->render();
}
$output->stopPaging();
}
}
示例2: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($this->command !== NULL) {
// Help for an individual command.
$output->page($this->command->asText());
$this->command = NULL;
} elseif ($name = $input->getArgument('command_name')) {
// Help for an individual command.
$output->page($this->getApplication()->get($name)->asText());
} else {
$categories = [];
// List available commands.
$commands = $this->getApplication()->all();
// Find the alignment width.
$width = 0;
foreach ($commands as $command) {
$width = strlen($command->getName()) > $width ? strlen($command->getName()) : $width;
}
$width += 2;
foreach ($commands as $name => $command) {
if ($name !== $command->getName()) {
continue;
}
if ($command->getAliases()) {
$aliases = sprintf(' <comment>Aliases:</comment> %s', implode(', ', $command->getAliases()));
} else {
$aliases = '';
}
if ($command instanceof DrushCommand) {
$category = (string) $command->getCategory();
} else {
$category = static::PSYSH_CATEGORY;
}
if (!isset($categories[$category])) {
$categories[$category] = [];
}
$categories[$category][] = sprintf(" <info>%-{$width}s</info> %s%s", $name, $command->getDescription(), $aliases);
}
$messages = [];
foreach ($categories as $name => $category) {
$messages[] = '';
$messages[] = sprintf('<comment>%s</comment>', OutputFormatter::escape($name));
foreach ($category as $message) {
$messages[] = $message;
}
}
$output->page($messages);
}
}
示例3: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
list($value, $reflector) = $this->getTargetAndReflector($input->getArgument('value'));
$output->page(function (ShellOutput $output) use($reflector) {
$output->writeln(SignatureFormatter::format($reflector));
$output->writeln(CodeFormatter::format($reflector), ShellOutput::OUTPUT_RAW);
});
}
示例4: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$incredulity = $input->getArgument('incredulity');
if (strlen(preg_replace('/[\\?!]/', '', $incredulity))) {
throw new \InvalidArgumentException('Incredulity must include only "?" and "!".');
}
$count = $input->getOption('verbose') ? PHP_INT_MAX : pow(2, max(0, strlen($incredulity) - 1));
$output->page($this->getBacktrace($this->context->getLastException(), $count), ShellOutput::NUMBER_LINES | ShellOutput::OUTPUT_RAW);
}
示例5: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$info = $this->fileInfo();
$num = $input->getOption('num');
$colors = new ConsoleColor();
$colors->addTheme('line_number', array('blue'));
$highlighter = new Highlighter($colors);
$contents = file_get_contents($info['file']);
$output->page($highlighter->getCodeSnippet($contents, $info['line'], $num, $num), ShellOutput::OUTPUT_RAW);
}
示例6: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$code = $input->getArgument('code');
if (strpos('<?', $code) === false) {
$code = '<?php ' . $code;
}
$depth = $input->getOption('depth');
$nodes = $this->parse($code);
$output->page($this->presenter->present($nodes, $depth));
}
示例7: execute
/**
*
* {@inheritdoc}
*
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
list($value, $reflector) = $this->getTargetAndReflector($input->getArgument('value'));
try {
$output->page(CodeFormatter::format($reflector), ShellOutput::OUTPUT_RAW);
} catch (RuntimeException $e) {
$output->writeln(SignatureFormatter::format($reflector));
throw $e;
}
}
示例8: execute
/**
* @param InputInterface $input
* @param OutputInterface|\Psy\Output\ShellOutput $output
*
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var \eZ\Publish\API\Repository\LocationService $locationService */
$locationService = $this->getScopeVariable('locationService');
$id = $input->getArgument('id');
if ($input->getOption('remote-id')) {
$location = $locationService->loadLocationByRemoteId($id);
} else {
$location = $locationService->loadLocation($id);
}
$output->page($this->presenter->present($location, 10, true, Presenter::VERBOSE));
}
示例9: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$code = $input->getArgument('code');
if (strpos('<?', $code) === false) {
$code = '<?php ' . $code;
}
$walker = $this->getWalker();
$nodes = $this->parse($code);
$depth = $input->getOption('depth');
$output->page(function (ShellOutput $output) use(&$walker, $nodes, $depth) {
$out = Inspector::export($nodes, $depth);
$walker($output, $out);
});
}
示例10: execute
/**
* @param InputInterface $input
* @param OutputInterface|\Psy\Output\ShellOutput $output
*
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var \eZ\Publish\API\Repository\Repository $repository */
$repository = $this->getScopeVariable('repository');
$contentService = $repository->getContentService();
$id = $input->getArgument('id');
if ($input->getOption('remote-id')) {
$method = $input->getOption('all') ? 'loadContentByRemoteId' : 'loadContentInfoByRemoteId';
$content = $contentService->{$method}($id);
} else {
$method = $input->getOption('all') ? 'loadContent' : 'loadContentInfo';
$content = $contentService->{$method}($id);
}
$output->page($this->presenter->present($content, 10, true, Presenter::VERBOSE));
}
示例11: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
list($value, $reflector) = $this->getTargetAndReflector($input->getArgument('value'));
$doc = $this->getManualDoc($reflector) ?: DocblockFormatter::format($reflector);
$output->page(function ($output) use($reflector, $doc) {
$output->writeln(SignatureFormatter::format($reflector));
if (empty($doc) && !$this->getApplication()->getManualDb()) {
$output->writeln('');
$output->writeln('<warning>PHP manual not found</warning>');
$output->writeln(' To document core PHP functionality, download the PHP reference manual:');
$output->writeln(' https://github.com/bobthecow/psysh#downloading-the-manual');
} else {
$output->writeln('');
$output->writeln($doc);
}
});
}
示例12: execute
/**
*
* {@inheritdoc}
*
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->validateOnlyOne($input, array('show', 'head', 'tail'));
$this->validateOnlyOne($input, array('save', 'replay', 'clear'));
$history = $this->getHistorySlice($input->getOption('show'), $input->getOption('head'), $input->getOption('tail'));
$highlighted = false;
$invert = $input->getOption('invert');
$insensitive = $input->getOption('insensitive');
if ($pattern = $input->getOption('grep')) {
if (substr($pattern, 0, 1) !== '/' || substr($pattern, -1) !== '/' || strlen($pattern) < 3) {
$pattern = '/' . preg_quote($pattern, '/') . '/';
}
if ($insensitive) {
$pattern .= 'i';
}
$this->validateRegex($pattern);
$matches = array();
$highlighted = array();
foreach ($history as $i => $line) {
if (preg_match($pattern, $line, $matches) xor $invert) {
if (!$invert) {
$chunks = explode($matches[0], $history[$i]);
$chunks = array_map(array(__CLASS__, 'escape'), $chunks);
$glue = sprintf('<urgent>%s</urgent>', self::escape($matches[0]));
$highlighted[$i] = implode($glue, $chunks);
}
} else {
unset($history[$i]);
}
}
} elseif ($invert) {
throw new \InvalidArgumentException('Cannot use -v without --grep.');
} elseif ($insensitive) {
throw new \InvalidArgumentException('Cannot use -i without --grep.');
}
if ($save = $input->getOption('save')) {
$output->writeln(sprintf('Saving history in %s...', $save));
file_put_contents($save, implode(PHP_EOL, $history) . PHP_EOL);
$output->writeln('<info>History saved.</info>');
} elseif ($input->getOption('replay')) {
if (!($input->getOption('show') || $input->getOption('head') || $input->getOption('tail'))) {
throw new \InvalidArgumentException('You must limit history via --head, --tail or --show before replaying.');
}
$count = count($history);
$output->writeln(sprintf('Replaying %d line%s of history', $count, $count !== 1 ? 's' : ''));
$this->getApplication()->addInput($history);
} elseif ($input->getOption('clear')) {
$this->clearHistory();
$output->writeln('<info>History cleared.</info>');
} else {
$type = $input->getOption('no-numbers') ? 0 : ShellOutput::NUMBER_LINES;
if (!$highlighted) {
$type = $type | ShellOutput::OUTPUT_RAW;
}
$output->page($highlighted ?: $history, $type);
}
}
示例13: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$incredulity = implode('', $input->getArgument('incredulity'));
if (strlen(preg_replace('/[\\?!]/', '', $incredulity))) {
throw new \InvalidArgumentException('Incredulity must include only "?" and "!".');
}
$exception = $this->context->getLastException();
$count = $input->getOption('verbose') ? PHP_INT_MAX : pow(2, max(0, strlen($incredulity) - 1));
$trace = $this->getBacktrace($exception, $count);
$shell = $this->getApplication();
$output->page(function ($output) use($exception, $trace, $shell) {
$shell->renderException($exception, $output);
$output->writeln('--');
$output->write($trace, true, ShellOutput::NUMBER_LINES);
});
}
示例14: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$trace = $this->getBacktrace(new \Exception(), $input->getOption('num'), $input->getOption('include-psy'));
$output->page($trace, ShellOutput::NUMBER_LINES);
}
示例15: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$args = $input->getArguments();
$first = array_shift($args);
// If the first argument is an alias, assign the next argument as the
// command.
if (strpos($first, '@') === 0) {
$alias = $first;
$command = array_shift($args);
} else {
$alias = '@self';
$command = $first;
}
$options = $input->getOptions();
// Force the 'backend' option to TRUE.
$options['backend'] = TRUE;
$return = drush_invoke_process($alias, $command, array_values($args), $options, ['interactive' => TRUE]);
if ($return['error_status'] > 0) {
foreach ($return['error_log'] as $error_type => $errors) {
$output->write($errors);
}
// Add a newline after so the shell returns on a new line.
$output->writeln('');
} else {
$output->page(drush_backend_get_result());
}
}