|
@@ -81,12 +81,18 @@ class Command
|
|
/**
|
|
/**
|
|
* Executes the current command.
|
|
* Executes the current command.
|
|
*
|
|
*
|
|
|
|
+ * This method is not abstract because you can use this class
|
|
|
|
+ * as a concrete class. In this case, instead of defining the
|
|
|
|
+ * execute() method, you set the code to execute by passing
|
|
|
|
+ * a Closure to the setCode() method.
|
|
|
|
+ *
|
|
* @param InputInterface $input An InputInterface instance
|
|
* @param InputInterface $input An InputInterface instance
|
|
* @param OutputInterface $output An OutputInterface instance
|
|
* @param OutputInterface $output An OutputInterface instance
|
|
*
|
|
*
|
|
* @return integer 0 if everything went fine, or an error code
|
|
* @return integer 0 if everything went fine, or an error code
|
|
*
|
|
*
|
|
* @throws \LogicException When this abstract class is not implemented
|
|
* @throws \LogicException When this abstract class is not implemented
|
|
|
|
+ * @see setCode()
|
|
*/
|
|
*/
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
{
|
|
@@ -119,8 +125,15 @@ class Command
|
|
/**
|
|
/**
|
|
* Runs the command.
|
|
* Runs the command.
|
|
*
|
|
*
|
|
|
|
+ * The code to execute is either defined directly with the
|
|
|
|
+ * setCode() method or by overriding the execute() method
|
|
|
|
+ * in a sub-class.
|
|
|
|
+ *
|
|
* @param InputInterface $input An InputInterface instance
|
|
* @param InputInterface $input An InputInterface instance
|
|
* @param OutputInterface $output An OutputInterface instance
|
|
* @param OutputInterface $output An OutputInterface instance
|
|
|
|
+ *
|
|
|
|
+ * @see setCode()
|
|
|
|
+ * @see execute()
|
|
*/
|
|
*/
|
|
public function run(InputInterface $input, OutputInterface $output)
|
|
public function run(InputInterface $input, OutputInterface $output)
|
|
{
|
|
{
|
|
@@ -154,9 +167,14 @@ class Command
|
|
/**
|
|
/**
|
|
* Sets the code to execute when running this command.
|
|
* Sets the code to execute when running this command.
|
|
*
|
|
*
|
|
|
|
+ * If this method is used, it overrides the code defined
|
|
|
|
+ * in the execute() method.
|
|
|
|
+ *
|
|
* @param \Closure $code A \Closure
|
|
* @param \Closure $code A \Closure
|
|
*
|
|
*
|
|
* @return Command The current instance
|
|
* @return Command The current instance
|
|
|
|
+ *
|
|
|
|
+ * @see execute()
|
|
*/
|
|
*/
|
|
public function setCode(\Closure $code)
|
|
public function setCode(\Closure $code)
|
|
{
|
|
{
|