Symfony\Component\Console\Command\Command::setAliases PHP Method

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
    public function setAliases($aliases)
    {
        if (!is_array($aliases) && !$aliases instanceof \Traversable) {
            throw new InvalidArgumentException('$aliases must be an array or an instance of \\Traversable');
        }
        foreach ($aliases as $alias) {
            $this->validateName($alias);
        }
        $this->aliases = $aliases;
        return $this;
    }

Usage Example

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'));
 }
All Usage Examples Of Symfony\Component\Console\Command\Command::setAliases