setAliases() public method

Sets the aliases for the command.
public setAliases ( string[] $aliases ) : Command
$aliases string[] An array of aliases for the command
return Command The current instance
Example #1
0
 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'));
 }
Example #2
0
 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'));
 }
Example #3
0
 /**
  * @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;
 }
Example #5
0
 public function setAliases($aliases)
 {
     return $this->innerCommand->setAliases($aliases);
 }
Example #6
0
 /**
  * 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.');
 }
Example #7
0
 /**
  * @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.');
 }
Example #8
0
 /**
  * @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)));
     }
 }