Пример #1
0
 /**
  * @param EmailModel  $emailModel
  * @param EmailEntity $parentEmailEntity
  */
 protected function initReplyAllFrom(EmailModel $emailModel, EmailEntity $parentEmailEntity)
 {
     $userEmails = $this->helper->getUser()->getEmails();
     $toEmails = [];
     $ccEmails = [];
     $emailRecipients = $parentEmailEntity->getTo();
     $emailCcRecipients = $parentEmailEntity->getCc();
     /** @var EmailRecipient $emailRecipient */
     foreach ($emailRecipients as $emailRecipient) {
         $toEmails[] = $emailRecipient->getEmailAddress()->getEmail();
     }
     /** @var EmailRecipient $emailCcRecipient */
     foreach ($emailCcRecipients as $emailCcRecipient) {
         $ccEmails[] = $emailCcRecipient->getEmailAddress()->getEmail();
     }
     $emailModel->setCc($ccEmails);
     foreach ($userEmails as $userEmail) {
         if (in_array($userEmail->getEmail(), $toEmails, true)) {
             $emailModel->setFrom($userEmail->getEmail());
             break;
         }
     }
 }