Sets the aliases for the command.
public setAliases ( string[] $aliases ) : |
||
$aliases | string[] | An array of aliases for the command |
Résultat | The current instance |
public function testBundleCommandCanBeFoundByAlias() { $command = new Command('example'); $command->setAliases(array('alias')); $bundle = $this->createBundleMock(array($command)); $kernel = $this->getKernel(array($bundle)); $application = new Application($kernel); $this->assertSame($command, $application->find('alias')); }
public function testBundleCommandCanBeFoundByAlias() { $bundle = $this->getMock('Symfony\\Component\\HttpKernel\\Bundle\\Bundle'); $bundle->expects($this->once())->method('registerCommands'); $kernel = $this->getKernel(array($bundle)); $application = new Application($kernel); $command = new Command('example'); $command->setAliases(array('alias')); $application->add($command); $this->assertSame($command, $application->find('alias')); }
/** * @param \Symfony\Component\Console\Command\Command $command */ protected function registerConfigCommandAlias(Command $command) { if ($this->hasConfigCommandAliases()) { foreach ($this->config['commands']['aliases'] as $alias) { if (!is_array($alias)) { continue; } $aliasCommandName = key($alias); $commandString = $alias[$aliasCommandName]; list($originalCommand) = explode(' ', $commandString); if ($command->getName() == $originalCommand) { $currentCommandAliases = $command->getAliases(); $currentCommandAliases[] = $aliasCommandName; $command->setAliases($currentCommandAliases); } } } }
/** * {@inheritdoc} */ public function setAliases($aliases) { $this->decoratedCommand->setAliases($aliases); return $this; }
public function setAliases($aliases) { return $this->innerCommand->setAliases($aliases); }
/** * Configures a console command by setting name, description, arguments, etc. * * @param Command $command */ public static function configure(Command $command) { $command->setName('config:status'); $command->setAliases(['status']); $command->setDescription('Shows the current migration status.'); }
/** * @inheritdoc */ public static function configure(Command $command) { $command->setName('config:init'); $command->setAliases(['init']); $command->setDescription('Initialises Baleen by creating a config file in the current directory.'); }
/** * @param Command $command */ public function registerConfigCommandAlias(Command $command) { foreach ($this->getArray(array('commands', 'aliases')) as $alias) { if (!is_array($alias)) { continue; } $aliasCommandName = key($alias); $commandString = $alias[$aliasCommandName]; list($originalCommand) = explode(' ', $commandString, 2); if ($command->getName() !== $originalCommand) { continue; } $command->setAliases(array_merge($command->getAliases(), array($aliasCommandName))); } }