1 | <?php |
||
38 | class BaseCommand extends Command |
||
39 | { |
||
40 | /** @var Container */ |
||
41 | protected $container; |
||
42 | |||
43 | /** |
||
44 | * A reference to the CommandBus in charge of handling Messages. |
||
45 | * |
||
46 | * @var CommandBus |
||
47 | */ |
||
48 | protected $commandBus; |
||
49 | |||
50 | /** @var string */ |
||
51 | protected $serviceAlias; |
||
52 | |||
53 | /** @var string */ |
||
54 | protected $serviceClass; |
||
55 | |||
56 | /** |
||
57 | * @param ContainerInterface $container A reference to the Application's Container. |
||
58 | * |
||
59 | * @param string $serviceAlias The key in the Container for the command that the instance of this class represents. |
||
60 | * |
||
61 | * @param string $serviceClass Needed in order to run certain checks against the class before instantiating it |
||
62 | * with the container. This helps us make those checks without triggering all the other |
||
63 | * services through the Container's DI functionality. |
||
64 | * |
||
65 | * @throws InvalidArgumentException |
||
66 | */ |
||
67 | public function __construct(ContainerInterface $container, $serviceAlias, $serviceClass) |
||
93 | |||
94 | /** |
||
95 | * @return Container |
||
96 | */ |
||
97 | public function getContainer() |
||
101 | |||
102 | /** |
||
103 | * getCommandBus. |
||
104 | * |
||
105 | * @return CommandBus |
||
106 | */ |
||
107 | public function getCommandBus() |
||
111 | |||
112 | /** |
||
113 | * Executes the current command by retrieving its associated Message from the Container, setting the Input and |
||
114 | * Output according to what was received as parameters, and finally passing that Message to the CommandBus for |
||
115 | * handling. |
||
116 | * |
||
117 | * @param InputInterface $input An InputInterface instance |
||
118 | * @param OutputInterface $output An OutputInterface instance |
||
119 | * |
||
120 | * @return int|null null or 0 if everything went fine, or an error code |
||
121 | * |
||
122 | * @throws InvalidArgumentException |
||
123 | */ |
||
124 | protected function execute(InputInterface $input, OutputInterface $output) |
||
142 | |||
143 | /** |
||
144 | * Calls the message's static "configure" public function passing $this as argument to allow the message to |
||
145 | * configure the command. |
||
146 | */ |
||
147 | protected function configure() |
||
152 | } |
||
153 |