public function handle(Command $command)
 {
     $progress = new PayrollReporter(0, $this->staff->countAll());
     $this->bus->execute(new BroadcastEvent(new PayrollDistributionStarted($progress)));
     foreach ($this->staff as $employee) {
         $progress = $progress->advance();
         $this->bus->execute(new SendPayroll($employee, $command->getMonth(), $command->getPaths(), $this->sender, $progress));
     }
     $this->bus->execute(new BroadcastEvent(new AllPayrollsWereSent($progress, $command->getMonth())));
 }
 /**
  * Gets the employee, prepares and sends an email message with the payrolls attached
  *
  * @param Command $command 
  * @return Events
  * @author Fran Iglesias
  */
 public function handle(Command $command)
 {
     $employee = $command->getEmployee();
     try {
         $this->sendEmail($employee, $command->getSender(), $command->getPaths(), $command->getMonth());
         $this->recorder->recordThat(new PayrollEmailWasSent($employee, $command->getProgress()->addSent()));
     } catch (EmployeeHasNoPayrollFiles $e) {
         $this->recorder->recordThat(new PayrollCouldNotBeFound($employee, $command->getProgress()->addNotFound()));
     } catch (\Swift_SwiftException $e) {
         $this->recorder->recordThat(new PayrollEmailCouldNotBeSent($employee, $e->getMessage(), $command->getProgress()->addFailed()));
     }
 }