/** * @param Email $email * * @return bool|string */ protected function getFromNameLink(Email $email) { $path = false; if ($email->getFromEmailAddress() && $email->getFromEmailAddress()->getOwner()) { $className = $email->getFromEmailAddress()->getOwner()->getClass(); $routeName = $this->configManager->getEntityMetadata($className)->getRoute('view', false); $path = $this->router->generate($routeName, ['id' => $email->getFromEmailAddress()->getOwner()->getId()]); } return $path; }
public function testFromEmailAddressGetterAndSetter() { $emailAddress = $this->getMock('Oro\\Bundle\\EmailBundle\\Entity\\EmailAddress'); $entity = new Email(); $entity->setFromEmailAddress($emailAddress); $this->assertTrue($emailAddress === $entity->getFromEmailAddress()); }
/** * Gets all(FROM, TO, CC, BCC) emails. * * @param Email $email * * @return string[] */ protected function getEmails(Email $email) { $emails = []; foreach ($email->getRecipients() as $recipient) { $emails[] = $recipient->getEmailAddress()->getEmail(); } $emails[] = $email->getFromEmailAddress()->getEmail(); return array_unique($emails); }
/** * @param array $targets * @param Email $email */ protected function addSenderOwner(&$targets, Email $email) { $from = $email->getFromEmailAddress(); if ($from) { $owner = $from->getOwner(); if ($owner) { $this->addTarget($targets, $owner); } } }
/** * @param array $targets * @param Email $email */ protected function addSenderOwner(&$targets, Email $email) { $from = $email->getFromEmailAddress(); if (!$from) { return; } $owner = $from->getOwner(); if (!$owner) { return; } // @todo: Should be deleted after email sync process will be refactored $token = $this->tokenStorage->getToken(); if ($token) { $ownerOrganization = $this->entityOwnerAccessorLink->getService()->getOrganization($owner); if ($ownerOrganization && $token instanceof OrganizationContextTokenInterface && $token->getOrganizationContext()->getId() !== $ownerOrganization->getId()) { return; } } $this->addTarget($targets, $owner); }
/** * @param EmailEntity $parentEmailEntity * * @return EmailModel */ public function createReplyAllEmailModel(EmailEntity $parentEmailEntity) { $emailModel = $this->factory->getEmail(); $emailModel->setMailType(EmailModel::MAIL_TYPE_REPLY); $emailModel->setParentEmailId($parentEmailEntity->getId()); $fromAddress = $parentEmailEntity->getFromEmailAddress(); if ($fromAddress->getOwner() === $this->helper->getUser()) { $toList = []; foreach ($parentEmailEntity->getTo() as $toRecipient) { $toEmail = $toRecipient->getEmailAddress()->getEmail(); $this->helper->preciseFullEmailAddress($toEmail); $toList[] = $toEmail; } $ccList = []; foreach ($parentEmailEntity->getCc() as $ccRecipient) { $toEmail = $ccRecipient->getEmailAddress()->getEmail(); $this->helper->preciseFullEmailAddress($toEmail); $ccList[] = $toEmail; } $emailModel->setTo($toList); $emailModel->setCc($ccList); $emailModel->setFrom($fromAddress->getEmail()); } else { $toEmail = $fromAddress->getEmail(); $this->helper->preciseFullEmailAddress($toEmail); $emailModel->setTo([$toEmail]); $this->initReplyAllFrom($emailModel, $parentEmailEntity); } $emailModel->setSubject($this->helper->prependWith('Re: ', $parentEmailEntity->getSubject())); $body = $this->helper->getEmailBody($parentEmailEntity, 'OroEmailBundle:Email/Reply:parentBody.html.twig'); $emailModel->setBodyFooter($body); $emailModel->setContexts($this->activityListProvider->getTargetEntities($parentEmailEntity)); return $this->createEmailModel($emailModel); }
/** * @param EmailEntity $parentEmailEntity * * @return EmailModel */ public function createReplyEmailModel(EmailEntity $parentEmailEntity) { $emailModel = $this->factory->getEmail(); $emailModel->setMailType(EmailModel::MAIL_TYPE_REPLY); $emailModel->setParentEmailId($parentEmailEntity->getId()); $fromAddress = $parentEmailEntity->getFromEmailAddress(); if ($fromAddress->getOwner() == $this->helper->getUser()) { $emailModel->setTo([$parentEmailEntity->getTo()->first()->getEmailAddress()->getEmail()]); $emailModel->setFrom($fromAddress->getEmail()); } else { $emailModel->setTo([$fromAddress->getEmail()]); $this->initReplyFrom($emailModel, $parentEmailEntity); } $emailModel->setSubject($this->helper->prependWith('Re: ', $parentEmailEntity->getSubject())); $body = $this->helper->getEmailBody($parentEmailEntity, 'OroEmailBundle:Email/Reply:parentBody.html.twig'); $emailModel->setBodyFooter($body); $emailModel->setContexts($this->activityListProvider->getTargetEntities($parentEmailEntity)); return $this->createEmailModel($emailModel); }