Baleen\Cli\BaseCommand

class BaseCommand

The base Command class used to build all the command definitions for the Application.

property container

protected Container

property commandBus

protected CommandBus

A reference to the CommandBus in charge of handling Messages.

property serviceAlias

protected string

property serviceClass

protected string

__construct(ContainerInterface $container, $serviceAlias, $serviceClass)
Parameters:
  • $container (ContainerInterface) – A reference to the Application’s Container.
  • $serviceAlias (string) – The key in the Container for the command that the instance of this class represents.
  • $serviceClass (string) – Needed in order to run certain checks against the class before instantiating it with the container. This helps us make those checks without triggering all the other services through the Container’s DI functionality.
getContainer()
Returns:Container
getCommandBus()

getCommandBus.

Returns:CommandBus
execute(InputInterface $input, OutputInterface $output)

Executes the current command by retrieving its associated Message from the Container, setting the Input and Output according to what was received as parameters, and finally passing that Message to the CommandBus for handling.

Parameters:
  • $input (InputInterface) – An InputInterface instance
  • $output (OutputInterface) – An OutputInterface instance
Returns:

int|null null or 0 if everything went fine, or an error code

configure()

Calls the message’s static “configure” public function passing $this as argument to allow the message to configure the command.