コード例 #1
0
ファイル: EditMemberService.php プロジェクト: semplon/mabes
 /**
  * @param CommandInterface $command
  * @return bool
  */
 public function execute(CommandInterface $command)
 {
     if (!$command instanceof EditMemberCommand) {
         throw new \DomainException("Internal error, silahkan hubungi CS kami");
     }
     $command->setRepository($this->member_repo);
     $violation = $this->validator->validate($command);
     if ($violation->count() > 0) {
         $message = $violation->get(0)->getMessage();
         throw new \DomainException($message);
     }
     //        $member = new Member();
     $member = $this->app->em->getRepository("Mabes\\Entity\\Member")->find($command->getAccountId());
     $member->setEmail($command->getEmail());
     $member->setAccountNumber($command->getAccountNumber());
     $member->setAccountHolder($command->getAccountHolder());
     $member->setBankName($command->getBankName());
     $member->setFullName($command->getFullname());
     $member->setAddress($command->getAddress());
     $member->setPhone($command->getPhone());
     $this->app->em->flush();
     //        $this->member_repo->save($member);
     $data = ["account_id" => $member->getAccountId(), "email" => $member->getEmail(), "phone" => $member->getPhone(), "fullname" => $member->getFullName(), "bank_name" => $member->getBankName(), "account_number" => $member->getAccountNumber(), "account_holder" => $member->getAccountHolder(), "address" => $member->getAddress(), "date" => date("Y-m-d H:i:s")];
     $this->event_emitter->emit("validation.created", [$data]);
     return true;
 }
コード例 #2
0
 /**
  * Output some contents.
  * @param  string $out The output.
  */
 public function output($out)
 {
     if (empty($this->emitter)) {
         $this->value .= $out;
     } else {
         $this->emitter->emit('output', array($out));
     }
 }
コード例 #3
0
 /**
  * This read sets the pending test count to 0
  * and immediately frees all workers.
  */
 public function read()
 {
     $this->pool->setPending([]);
     $workers = $this->pool->getWorkers();
     foreach ($workers as $worker) {
         $this->emitter->emit('peridot.concurrency.worker.completed', [$worker]);
     }
 }
コード例 #4
0
 /**
  * Emit an event
  *
  * @param string $event
  * @param array  $arguments
  *
  * @return Void
  */
 public function emit($event, array $arguments = array())
 {
     foreach ($this->anyListeners as $listener) {
         call_user_func_array($listener, [$event, $arguments]);
     }
     parent::emit($event, $arguments);
 }
コード例 #5
0
 public function execute(CommandInterface $command)
 {
     if (!$command instanceof CreateIslamicAccountCommand) {
         throw new \DomainException("Internal error, silahkan hubungi CS kami");
     }
     $command->setRepository($this->member_repo);
     $violation = $this->validator->validate($command);
     if ($violation->count() > 0) {
         $message = $violation->get(0)->getMessage();
         throw new \DomainException($message);
     }
     $member = $this->member_repo->findOneBy(["account_id" => $command->getAccountId()]);
     $data = ["account_id" => $command->getAccountId(), "mt4_account" => $command->getMt4Account(), "fullname" => $member->getFullname(), "phone" => $member->getPhone(), "email" => $member->getEmail(), "date" => date("Y-m-d H:i:s")];
     $this->event_emitter->emit("akun.islami.created", [$data]);
     return true;
 }
コード例 #6
0
 public function testPendingThenWaiting()
 {
     $stream = new EventEmitter();
     $buf = new BufferedReader($stream);
     $this->assertPromiseYields("line1\n", $buf->readline());
     $stream->emit('data', ["line1\nline2\n"]);
     $this->assertPromiseYields("line2\n", $buf->readline());
 }
コード例 #7
0
 public function execute(CommandInterface $command)
 {
     if (!$command instanceof DepositMarkAsFailedCommand) {
         throw new \DomainException("Internal error, silahkan hubungi CS kami");
     }
     $command->setRepository($this->deposit_repository);
     $violation = $this->validator->validate($command);
     if ($violation->count() > 0) {
         $message = $violation->get(0)->getMessage();
         throw new \DomainException($message);
     }
     $deposit = $this->deposit_repository->findOneBy(["deposit_id" => $command->getDepositId()]);
     $deposit->setStatus(Deposit::STATUS_FAILED);
     $this->deposit_repository->save($deposit);
     $data = ["email" => $deposit->getClient()->getEmail(), "ticket" => $deposit->getDepositId(), "full_name" => $deposit->getClient()->getFullName(), "account_id" => $deposit->getClient()->getAccountId(), "amount_idr" => $deposit->getAmountIdr(), "amount_usd" => $deposit->getAmountUsd(), "bank_name" => $deposit->getToBank(), "date" => date("Y-m-d H:i:s")];
     $this->event_emitter->emit("admin.deposit.failed", [$data]);
     return true;
 }
コード例 #8
0
 public function execute(CommandInterface $command)
 {
     if (!$command instanceof WithdrawalMarkAsDoneCommand) {
         throw new \DomainException("Internal error, silahkan hubungi CS kami");
     }
     $command->setRepository($this->withdrawal_repository);
     $violation = $this->validator->validate($command);
     if ($violation->count() > 0) {
         $message = $violation->get(0)->getMessage();
         throw new \DomainException($message);
     }
     $withdrawal = $this->withdrawal_repository->findOneBy(["withdrawal_id" => $command->getWithdrawalId()]);
     $withdrawal->setStatus(Withdrawal::STATUS_PROCESSED);
     $this->withdrawal_repository->save($withdrawal);
     $data = ["email" => $withdrawal->getClient()->getEmail(), "account_id" => $withdrawal->getClient()->getAccountId(), "full_name" => $withdrawal->getClient()->getFullName(), "ticket" => $withdrawal->getWithdrawalId(), "amount" => $withdrawal->getAmount(), "bank_name" => $withdrawal->getClient()->getBankName(), "account_number" => $withdrawal->getClient()->getAccountNumber(), "account_holder" => $withdrawal->getClient()->getAccountHolder(), "date" => date("Y-m-d H:i:s")];
     $this->event_emitter->emit("admin.withdrawal.processed", [$data]);
     return true;
 }
コード例 #9
0
ファイル: Command.php プロジェクト: tomaszdurka/php-exec
 /**
  * @param string|null $input
  * @throws Exception
  * @return Result
  */
 public function run($input = null)
 {
     $command = $this->_getCommand();
     $descriptorSpec = [0 => ["pipe", "r"], 1 => ["pipe", "w"], 2 => ["pipe", "w"]];
     $process = proc_open($command, $descriptorSpec, $pipes);
     if (!is_resource($process)) {
         throw new Exception('Cannot open command file pointer to `' . $command . '`');
     }
     $processStatus = proc_get_status($process);
     $this->_eventEmitter->emit('start', [$processStatus['pid']]);
     if (null !== $input) {
         fwrite($pipes[0], (string) $input);
     }
     fclose($pipes[0]);
     $stdout = null;
     $stderr = null;
     do {
         $readPipes = [$pipes[1], $pipes[2]];
         $writePipes = [];
         $exceptPipes = [];
         stream_select($readPipes, $writePipes, $exceptPipes, null);
         foreach ($readPipes as $readPipe) {
             $content = fread($readPipe, 4096);
             $streamType = array_search($readPipe, $pipes);
             switch ($streamType) {
                 case 1:
                     $stdout .= $content;
                     $this->_eventEmitter->emit('stdout', [$content]);
                     break;
                 case 2:
                     $stderr .= $content;
                     $this->_eventEmitter->emit('stderr', [$content]);
                     break;
             }
         }
         $processStatus = proc_get_status($process);
     } while ($processStatus['running']);
     fclose($pipes[1]);
     fclose($pipes[2]);
     $exitCode = $processStatus['exitcode'];
     $this->_eventEmitter->emit('stop', [$exitCode]);
     return new Result($this, $exitCode, $stdout, $stderr);
 }
コード例 #10
0
 public function execute(CommandInterface $command)
 {
     if (!$command instanceof AddInvestorPasswordCommand) {
         throw new \DomainException("Internal error, silahkan hubungi CS kami");
     }
     $command->setRepository($this->member_repo);
     $violation = $this->validator->validate($command);
     if ($violation->count() > 0) {
         $message = $violation->get(0)->getMessage();
         throw new \DomainException($message);
     }
     $member = $this->member_repo->findOneBy(["account_id" => $command->getAccountId()]);
     $investor_password = new InvestorPassword();
     $investor_password->setInvestorPassword($command->getInvestorPassword());
     $investor_password->setMtAccount($command->getMt4Account());
     $investor_password->setAccountId($member);
     $this->investor_password_repo->save($investor_password);
     $data = ["email" => $member->getEmail(), "account_id" => $member->getAccountId(), "fullname" => $member->getFullName(), "mt4_account" => $investor_password->getMtAccount(), "investor_password" => $investor_password->getInvestorPassword(), "date" => date("Y-m-d H:i:s")];
     $this->event_emitter->emit("investor.password.created", [$data]);
     return true;
 }
コード例 #11
0
ファイル: ClaimRebateService.php プロジェクト: semplon/mabes
 public function execute(CommandInterface $command)
 {
     if (!$command instanceof ClaimRebateCommand) {
         throw new \DomainException("Internal error, silahkan hubungi CS kami");
     }
     $command->setRepository($this->member_repo);
     $violation = $this->validator->validate($command);
     if ($violation->count() > 0) {
         $message = $violation->get(0)->getMessage();
         throw new \DomainException($message);
     }
     $member = $this->member_repo->findOneBy(["account_id" => $command->getAccountId()]);
     $claim_rebate = new ClaimRebate();
     $claim_rebate->setMember($member);
     $claim_rebate->setMt4Account($command->getMt4Account());
     $claim_rebate->setType($command->getType());
     $this->claim_rebate_repo->save($claim_rebate);
     $data = ["email" => $member->getEmail(), "account_id" => $member->getAccountId(), "fullname" => $member->getFullName(), "type" => $claim_rebate->getType(), "mt4_account" => $claim_rebate->getMt4Account(), "bank_name" => $member->getBankName(), "account_number" => $member->getAccountNumber(), "account_holder" => $member->getAccountHolder(), "date" => date("Y-m-d H:i:s")];
     $this->event_emitter->emit("claim.rebate.created", [$data]);
     return true;
 }
コード例 #12
0
 public function testMuteListener()
 {
     $listenersCalled = 0;
     $listener = function () use(&$listenersCalled) {
         $listenersCalled++;
     };
     $this->emitter->on('foo', $listener);
     $this->emitter->on('foo', function () use(&$listenersCalled) {
         $listenersCalled++;
         return;
     });
     $this->emitter->mute('foo', $listener);
     $this->emitter->emit('foo');
     $this->assertEquals(1, $listenersCalled);
     $this->emitter->unMute('foo', $listener);
     $this->emitter->emit('foo');
     $this->assertEquals(3, $listenersCalled);
 }
コード例 #13
0
 /**
  * Emit broadcasts an event from the message, and if the broker
  * is set on this message, the same event is broadcast on the broker.
  *
  * @param $event
  * @param array $arguments
  * @return void
  */
 public function emit($event, array $arguments = [])
 {
     parent::emit($event, $arguments);
     if ($this->broker) {
         $this->broker->emit($event, $arguments);
     }
 }