Ejemplo n.º 1
0
 public function handle(Command $command)
 {
     $Post = $this->repository->get(new PostId($command->getId()));
     $Post->update(new PostContent($command->getTitle(), $command->getBody()));
     $this->recorder->load($Post->retrieveEvents());
     $this->repository->save($Post);
 }
 public function handle(Command $command)
 {
     $devices = $command->getDevices();
     foreach ($devices as $device) {
         $this->monitor->poll($device);
         $this->recorder->load($this->monitor->getEvents());
     }
 }
 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())));
 }
Ejemplo n.º 4
0
 /**
  * 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()));
     }
 }
 public function handle(Command $command)
 {
     $this->recorder->recordThat($command->getEvent());
 }