本文整理汇总了PHP中Symfony\Component\Console\Command\Command::asText方法的典型用法代码示例。如果您正苦于以下问题:PHP Command::asText方法的具体用法?PHP Command::asText怎么用?PHP Command::asText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Command\Command
的用法示例。
在下文中一共展示了Command::asText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if (is_null($this->command)) {
$this->command = $this->getApplication()->get($input->getArgument('command_name'));
}
$output->writeln($this->command->asText());
}
示例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: asText
/**
* Returns the text representation of the command.
*
* @return string The string that represents the command
*/
public function asText()
{
$app = $this->getApplication()->getApp();
$txt = $app['app.signature'] . "\n" . parent::asText();
return $txt;
}
示例4: asText
public function asText()
{
return $this->innerCommand->asText();
}