本文整理汇总了PHP中Symfony\Component\Console\Command\Command::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Command::getName方法的具体用法?PHP Command::getName怎么用?PHP Command::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Command\Command
的用法示例。
在下文中一共展示了Command::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assert
/**
* @param $condition
* @param $message
*/
private function assert($condition, $message)
{
if ($condition) {
return;
}
throw new RuntimeException(sprintf('Command %s is not available because %s.', $this->command->getName(), $message));
}
示例2: getDependencies
/**
* @param Command $command
* @return array
*/
public function getDependencies(Command $command)
{
if (!array_key_exists($command->getName(), $this->commands)) {
return [];
}
return array_keys($this->commands[$command->getName()]);
}
示例3: testExecute
/**
* Test executing "mark_migration"
*
* @return void
*/
public function testExecute()
{
$commandTester = new CommandTester($this->command);
$commandTester->execute(['command' => $this->command->getName(), 'version' => '20150416223600', '--connection' => 'test']);
$this->assertContains('Migration successfully marked migrated !', $commandTester->getDisplay());
$result = $this->Connection->newQuery()->select(['*'])->from('phinxlog')->execute()->fetch('assoc');
$this->assertEquals('20150416223600', $result['version']);
}
示例4: getCommandName
/**
* {@inheritdoc}
*/
protected function getCommandName(InputInterface $input)
{
$stream = $this->getStdinStream();
$hasStdin = $stream->getSize() > 0;
$this->pluginCommand->setStream($stream);
return $hasStdin ? $this->pluginCommand->getName() : $this->generateCommand->getName();
}
示例5: describeCommand
/**
* @inheritdoc
*/
protected function describeCommand(Command $command, array $options = [])
{
$command->getSynopsis();
$command->mergeApplicationDefinition(false);
$this->write($command->getName() . "\n" . str_repeat('-', strlen($command->getName())) . "\n");
if ($description = $command->getDescription()) {
$this->write("{$description}\n\n");
}
$aliases = $command instanceof CommandBase ? $command->getVisibleAliases() : $command->getAliases();
if ($aliases) {
$this->write('Aliases: ' . '`' . implode('`, `', $aliases) . '`' . "\n\n");
}
$executableName = 'platform';
$this->write("## Usage:\n\n```\n{$executableName} " . $command->getSynopsis() . "\n```\n\n");
if ($help = $command->getProcessedHelp()) {
$this->write($help);
$this->write("\n\n");
}
if ($command->getNativeDefinition()) {
$this->describeInputDefinition($command->getNativeDefinition());
$this->write("\n\n");
}
if ($command instanceof CommandBase && ($examples = $command->getExamples())) {
$this->write('## Examples');
$this->write("\n");
$name = $command->getName();
foreach ($examples as $arguments => $description) {
$this->write("\n* {$description}: \n ```\n platform {$name} {$arguments}\n ```\n");
}
$this->write("\n");
}
}
示例6: execute
private function execute(array $fileStructure, array $options = []) : CommandTester
{
$fs = vfsStream::create($fileStructure, vfsStream::setup(getcwd()));
$commandTester = new CommandTester($this->command);
$commandTester->execute(array_merge(['command' => $this->command->getName(), 'path' => $fs->url()], $options));
return $commandTester;
}
示例7: testDumpCommandExecute
public function testDumpCommandExecute()
{
/** @var OrganizeCommand $command */
$noTagDir = __DIR__ . '/NO_TAG';
$this->commandTester->execute(['command' => $this->command->getName(), 'output-dir' => __DIR__, '--file-dir' => realpath(__DIR__ . '/../'), '--dump-command' => ' ', '--move-untagged-to' => $noTagDir]);
$output = $this->commandTester->getDisplay();
$outputArray = array_map('trim', explode(PHP_EOL, $output));
$this->assertEquals('mv \'' . realpath(__DIR__ . '/../') . '/toddle.mp3\' \'' . __DIR__ . '/2003/Celtic/toddle.mp3\'', $outputArray[0]);
$this->assertEquals('mv \'' . realpath(__DIR__ . '/../') . '/wrong_file.mp3\' \'' . __DIR__ . '/NO_TAG/wrong_file.mp3\'', $outputArray[1]);
}
示例8: __construct
/**
* Unique file name pid file name.
*
* @param Command $command
* @param null|string $tmpDirectory
*/
public function __construct(Command $command, $tmpDirectory = null)
{
$tmpDirectory = $tmpDirectory ? $tmpDirectory : sys_get_temp_dir();
if (!is_dir($tmpDirectory) or !is_writable($tmpDirectory)) {
throw new \RuntimeException(sprintf('The directory "%s" is not writable.', $tmpDirectory), 0, null, $tmpDirectory);
}
$partName = preg_replace('/[^a-z0-9\\._-]+/i', '-', $command->getName());
$partName = substr($partName, 0, 40);
$this->pidFile = sprintf('%s/atl.%s.%s.pid', $tmpDirectory, $partName, hash('sha256', $command->getName()));
}
示例9: it_opens_a_dialog_to_select_the_entity_and_count_if_no_entity_given
/** @test */
public function it_opens_a_dialog_to_select_the_entity_and_count_if_no_entity_given()
{
/** @var SymfonyQuestionHelper $question */
$question = $this->command->getHelper('question');
$question->setInputStream($this->getInputStream("1\n5\n"));
$this->commandTester->execute(['command' => $this->command->getName()]);
$count = $this->getDatabaseCount(App::class, []);
$this->assertEquals(5, $count);
$this->assertContains(sprintf('%s seeded.', App::class), $this->commandTester->getDisplay());
}
示例10: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|null|void
*
* @throws \Exception
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$ssh = $this->getApplication()->find($this->vagrant_ssh);
$arguments = $this->basicGetArgumentsWithoutSelf($input);
$options = $input->getOptions();
$parameters = array('command' => $this->vagrant_ssh, '--ssh_command' => $this->command->getName(), '--ssh_command_arguments' => $this->basicProceedArray($arguments), '--ssh_command_options' => $this->basicProceedArray($options));
$output->writeln($this->helper->formatSection('Info', json_encode($parameters)));
$greetInput = new ArrayInput($parameters);
$returnCode = $ssh->run($greetInput, $output);
$output->writeln($this->helper->formatSection('Finishing', $returnCode));
}
示例11: testExecuteWithoutShopId
/**
* Check if table without shop id was created as expected.
*/
public function testExecuteWithoutShopId()
{
$defaultStorage = 'ongr_sync_storage_0';
$commandTester = new CommandTester($this->executeCommand);
$commandTester->execute(['command' => $this->executeCommand->getName(), 'storage' => SyncStorage::STORAGE_MYSQL]);
$this->assertEquals('Storage successfully created for ' . SyncStorage::STORAGE_MYSQL . '.' . PHP_EOL, $commandTester->getDisplay());
$actual = $this->getConnection()->getSchemaManager()->listTableDetails($defaultStorage);
$this->getConnection()->getSchemaManager()->dropTable($defaultStorage);
$this->importData('SyncStorage/storageWithoutShop.sql');
$expected = $this->getConnection()->getSchemaManager()->listTableDetails($defaultStorage);
$this->compareTable($expected, $actual);
}
示例12: describeCommand
/**
* {@inheritdoc}
*/
protected function describeCommand(Command $command, array $options = array())
{
$command->getSynopsis();
$command->mergeApplicationDefinition(false);
$markdown = $command->getName() . "\n" . str_repeat('-', strlen($command->getName())) . "\n\n" . '* Description: ' . ($command->getDescription() ?: '<none>') . "\n" . '* Usage: `' . $command->getSynopsis() . '`' . "\n" . '* Aliases: ' . (count($command->getAliases()) ? '`' . implode('`, `', $command->getAliases()) . '`' : '<none>');
if ($help = $command->getProcessedHelp()) {
$markdown .= "\n\n" . $help;
}
if ($definitionMarkdown = $this->describeInputDefinition($command->getNativeDefinition())) {
$markdown .= "\n\n" . $definitionMarkdown;
}
return $markdown;
}
示例13: cmdNameToResourceName
protected function cmdNameToResourceName(Command $command, Page $parentPage)
{
$conf = $parentPage->getConfig();
$strategy = self::CHILDNAME_STRATEGY_PREFIX;
if (array_key_exists(self::CONF_CHILDNAME_STRATEGY, $conf)) {
$strategy = $conf[self::CONF_CHILDNAME_STRATEGY];
}
if ($strategy === self::CHILDNAME_STRATEGY_PREFIX) {
return sprintf('%s__%s.html', $parentPage->getName(), str_replace(':', '__', $command->getName()));
} else {
return sprintf('%s.html', str_replace(':', '__', $command->getName()));
}
}
示例14: __construct
public function __construct(Command $singleCommand)
{
global $argv;
$this->singleCommand = $singleCommand;
// Use the command's name as the whole app's name
$this->setName($singleCommand->getName());
// Then set the command's name to be the name of the script file
// executed (as executed, regardless of symlinks, etc) - i.e.
// whatever's set as $argv[0] - because this name ends up displayed in
// the "Usage" line of the `--help` output. Though we use the executed
// script's base name (i.e. none of the directories leading to it)
// because including any parts of the directory path results in a
// `--help` output that's very different to all native/standard
// commands.
// This will result in the "Usage" section displaying as:
// my-command.php [options] [--] <arguments>
// instead of showing the name of the command in place of
// 'my-command.php', which is especially useful for single-command
// apps, as the command name is never even referenced anywhere else!
$commandName = isset($argv[0]) ? basename($argv[0]) : 'command.php';
$singleCommand->setName($commandName);
parent::__construct();
$this->add($singleCommand);
$this->setDefaultCommand($singleCommand->getName());
// If the command class has an 'APP_VERSION' constant defined, we use
// that as the entire app's version, as this seems like a much more
// sensible place to indicate the version than in the Application
// constructor which is tucked away in a non-obvious place!
$commandClass = get_class($singleCommand);
if (defined($commandClass . '::APP_VERSION')) {
$this->setVersion(constant($commandClass . '::APP_VERSION'));
}
}
示例15: doRunCommand
/**
* @inheritdoc
*/
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
{
if ($command->getName() != 'version') {
$output->writeln($this->getLongVersion());
}
return parent::doRunCommand($command, $input, $output);
}