コード例 #1
0
 /**
  * @param ActionDto $dto
  * @return null
  */
 public function processAction(ActionDto $dto)
 {
     $container = Registry::get('container');
     $commandName = $dto->get('command');
     /** @var CommandHandlerInterface $command */
     $command = $container['command_' . $commandName];
     if (null === $command) {
         return;
     }
     $command->processCommand($dto->get('args'), $dto->get('channel'));
 }
コード例 #2
0
 /**
  * @param ActionDto $dto
  * @return null
  */
 public function processAction(ActionDto $dto)
 {
     if ($this->conditionResolver->isConditionMet($dto->get('condition'), Variables::all())) {
         $this->processActions($dto->get('then'));
     } else {
         $else = $dto->get('else');
         if (is_array($else) && count($else) > 0) {
             $this->processActions($else);
         }
     }
 }
コード例 #3
0
 /**
  * @param ActionDto $dto
  * @return null
  */
 private function processUntilLoop(ActionDto $dto)
 {
     $actions = $dto->get('actions');
     while (!$this->conditionResolver->isConditionMet($dto->get('condition'), Variables::all())) {
         if (true === Variables::get('flowcontrol.continue')) {
             Variables::remove('flowcontrol.continue');
             continue;
         }
         if (true === Variables::get('flowcontrol.break')) {
             Variables::remove('flowcontrol.break');
             break;
         }
         $this->processActions($actions);
     }
 }
コード例 #4
0
 /**
  * @param ActionDto $dto
  * @return null
  */
 public function processAction(ActionDto $dto)
 {
     $name = $dto->get('name');
     $value = $dto->get('value');
     switch ((string) $value) {
         case 'increment':
             Variables::set($name, Variables::get($name) + 1);
             break;
         case 'decrement':
             Variables::set($name, Variables::get($name) - 1);
             break;
         default:
             Variables::set($name, $value);
     }
 }
コード例 #5
0
 /**
  * @param ActionDto $dto
  * @return null
  */
 public function processAction(ActionDto $dto)
 {
     $this->dtoData = $dto->getData();
     $recipient = $dto->get('recipient');
     $this->recipientId = $this->slackFacade->getUserIdByName(str_replace('@', '', $recipient));
     $messages = $dto->get('messages');
     // 1. Send "before" message
     $beforeMessage = Ar::get($messages, 'before');
     if (null !== $beforeMessage) {
         $this->slackFacade->getSlackApi()->chatPostMessage($this->recipientId, $beforeMessage);
     }
     // 2. Register timed message handler
     $this->handlerId = uniqid();
     $start = time();
     $finish = $start + $this->getTimeoutSize($dto->get('timeout'));
     $this->coreProcessor->addTimedMessageHandler($this->handlerId, [$this, 'checker'], [$this, 'handler'], $start, $finish);
 }
コード例 #6
0
 /**
  * @param ActionDto $dto
  * @return null
  */
 public function processAction(ActionDto $dto)
 {
     $recipients = preg_split('/\\s*,\\s*/', $dto->get('recipients'));
     if (0 === count($recipients)) {
         return;
     }
     $recipientIds = [];
     foreach ($recipients as $recipient) {
         if ($recipient !== null) {
             $recipientIds[] = $this->slackFacade->getRecipientIdByName($recipient);
         }
     }
     if (0 === count($recipientIds)) {
         return;
     }
     $message = $dto->getMessage();
     $message = $this->substituteVariables($message);
     $dto->setData(array_merge($dto->getData(), ['message' => $message]));
     $this->outputManager->sendMessage($dto);
 }
コード例 #7
0
 /**
  * @param ActionDto $dto
  * @param array $data
  */
 protected function populateActionDto(ActionDto $dto, $data)
 {
     $dto->setData($data);
 }
コード例 #8
0
 /**
  * @param ActionDto $dto
  */
 public function sendMessage(ActionDto $dto)
 {
     $recipients = $this->parseRecipients($dto->getRecipients());
     $this->slackFacade->multiSendMessage($recipients, $dto->getMessage(), ['as_user' => true]);
 }
コード例 #9
0
 /**
  * @param ActionDto $dto
  * @return bool
  */
 public function canProcessAction(ActionDto $dto)
 {
     return 'break' === $dto->getAction();
 }
コード例 #10
0
 /**
  * @param ActionDto $dto
  * @return bool
  */
 public function canProcessAction(ActionDto $dto)
 {
     return 'continue' === $dto->getAction();
 }
コード例 #11
0
 /**
  * @param ActionDto $dto
  * @param $data
  */
 private function populateDto(ActionDto $dto, $data)
 {
     $dto->setData($data);
 }