Пример #1
0
 /**
  * @return ViewModel
  */
 public function listAction()
 {
     $messageId = $this->params('messageId');
     $queue = $this->manager->getList(['m.entityId = :messageId'], [], ['messageId' => $messageId]);
     if (null === $queue) {
         return $this->redirect()->toRoute(static::ERROR_ROUTE);
     }
     /** @var QueueItem $queueItem */
     foreach ($queue as $queueItem) {
         $this->prepareMessageBuilder($queueItem);
         $message = $queueItem->getMessage();
         $message->setSubject($this->messageBuilder->template($message->getSubject()));
     }
     return new ViewModel(['queue' => $queue, 'messageId' => $messageId]);
 }
Пример #2
0
 /**
  * @param QueueItem $queueItem
  */
 protected function safeSend(QueueItem $queueItem)
 {
     $now = new \DateTime("now");
     $queueItem->setAckedAt($now);
     $this->saveQueueItem($queueItem);
     $message = $queueItem->getMessage();
     $campaign = $message->getCampaign();
     $template = $campaign->getTemplate();
     $subscriber = $queueItem->getSubscriber();
     $this->messageBuilder->setEntityVars($message, $campaign, $template, $subscriber, $queueItem);
     $headers = $this->messageBuilder->getHeaders();
     $messageBody = $this->messageBuilder->getBody($message->getBody(), $template->getBody());
     $subject = $this->messageBuilder->template($message->getSubject());
     $this->mail($subscriber, $campaign, $subject, $messageBody, $headers);
     $queueItem->setSentAt($now);
     $this->saveQueueItem($queueItem);
 }