/** * @param array $from * * @return string */ protected function buildFullEmailAddress(array $from) { foreach ($from as $email => $name) { return $this->emailAddressHelper->buildFullEmailAddress($email, $name); } throw new \InvalidArgumentException('Sender email and name is empty'); }
/** * @param string $emailAddress * @param string|null $ownerClass * @param mixed|null $ownerId */ protected function preciseFullEmailAddress(&$emailAddress, $ownerClass = null, $ownerId = null) { if (!$this->emailAddressHelper->isFullEmailAddress($emailAddress)) { if (!empty($ownerClass) && !empty($ownerId)) { $owner = $this->entityRoutingHelper->getEntity($ownerClass, $ownerId); if ($owner) { $ownerName = $this->nameFormatter->format($owner); if (!empty($ownerName)) { $emailAddress = $this->emailAddressHelper->buildFullEmailAddress($emailAddress, $ownerName); return; } } } $repo = $this->emailAddressManager->getEmailAddressRepository($this->em); $emailAddressObj = $repo->findOneBy(array('email' => $emailAddress)); if ($emailAddressObj) { $owner = $emailAddressObj->getOwner(); if ($owner) { $ownerName = $this->nameFormatter->format($owner); if (!empty($ownerName)) { $emailAddress = $this->emailAddressHelper->buildFullEmailAddress($emailAddress, $ownerName); } } } } }
/** * Get email address prepared for sending. * * @param mixed $context * @param string|array $data * * @return string */ protected function getEmailAddress($context, $data) { $name = null; $emailAddress = $this->contextAccessor->getValue($context, $data); if (is_array($data)) { $emailAddress = $this->contextAccessor->getValue($context, $data['email']); if (array_key_exists('name', $data)) { $data['name'] = $this->contextAccessor->getValue($context, $data['name']); if (is_object($data['name'])) { $name = $this->entityNameResolver->getName($data['name']); } else { $name = $data['name']; } } } return $this->emailAddressHelper->buildFullEmailAddress($emailAddress, $name); }
/** * @param object|null $owner * @param string $email * * @return string */ protected function formatEmail($owner, $email) { if (!$owner) { return $email; } $ownerName = $this->nameFormatter->format($owner); return $this->emailAddressHelper->buildFullEmailAddress($email, $ownerName); }
/** * @param User $user * * @return string */ public function buildFullEmailAddress(User $user) { return $this->emailAddressHelper->buildFullEmailAddress($user->getEmail(), $this->entityNameResolver->getName($user)); }
/** * @dataProvider buildFullEmailAddressProvider */ public function testBuildFullEmailAddress($pureEmailAddress, $name, $fullEmailAddress) { $this->assertEquals($fullEmailAddress, $this->helper->buildFullEmailAddress($pureEmailAddress, $name)); }