execute() public method

Traditionally you should not provide any context to the execute method, as this implies knowledge of where the command is invoked. Any context should be provided at command creation time via dependency injection. The context provided might know how to get additional information at execution time from objects it knows about. Context provided can also be a mock (for unittesting)
public execute ( )
Example #1
0
 /**
  * helper method
  * 
  * @param ICommand $command            
  * @throws Exception
  */
 protected function execute(ICommand $command)
 {
     try {
         $command->execute();
     } catch (\Exception $e) {
         // command failure
         $e = new Exception($e->getMessage(), Exception::COMMAND_EXECUTION_FAILURE, $e);
         throw $e;
     }
 }