コード例 #1
0
ファイル: EmailTransport.php プロジェクト: antrampa/crm
 /**
  * @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');
 }
コード例 #2
0
ファイル: EmailHandler.php プロジェクト: xamin123/platform
 /**
  * @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);
                 }
             }
         }
     }
 }
コード例 #3
0
 /**
  * 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);
 }
コード例 #4
0
 /**
  * @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);
 }
コード例 #5
0
 /**
  * @param User $user
  *
  * @return string
  */
 public function buildFullEmailAddress(User $user)
 {
     return $this->emailAddressHelper->buildFullEmailAddress($user->getEmail(), $this->entityNameResolver->getName($user));
 }
コード例 #6
0
 /**
  * @dataProvider buildFullEmailAddressProvider
  */
 public function testBuildFullEmailAddress($pureEmailAddress, $name, $fullEmailAddress)
 {
     $this->assertEquals($fullEmailAddress, $this->helper->buildFullEmailAddress($pureEmailAddress, $name));
 }