Esempio n. 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $staff = new Staff();
     $staff->setUsername($input->getArgument("username"));
     $staff->setPassword($input->getArgument("password"));
     $this->slim_app->em->persist($staff);
     $this->slim_app->em->flush();
 }
Esempio n. 2
0
 public function execute(CommandInterface $command)
 {
     if (!$command instanceof CreateStaffCommand) {
         throw new \DomainException("Internal error, silahkan hubungi CS kami");
     }
     $command->setRepository($this->staff_repository);
     $violation = $this->validator->validate($command);
     if ($violation->count() > 0) {
         $message = $violation->get(0)->getMessage();
         throw new \DomainException($message);
     }
     $staff = new Staff();
     $this->hash_service->setRawPassword($command->getPassword());
     $staff->setUsername($command->getUsername());
     $staff->setPassword($this->hash_service->hash());
     $this->staff_repository->save($staff);
     return true;
 }