/**
  * @param string      $emailAddress
  * @param string|null $ownerClass
  * @param mixed|null  $ownerId
  * @param bool        $excludeCurrentUser
  */
 public function preciseFullEmailAddress(&$emailAddress, $ownerClass = null, $ownerId = null, $excludeCurrentUser = false)
 {
     if (!$this->emailAddressHelper->isFullEmailAddress($emailAddress)) {
         if (!empty($ownerClass) && !empty($ownerId)) {
             $owner = $this->entityRoutingHelper->getEntity($ownerClass, $ownerId);
             if ($owner) {
                 if ($this->doExcludeCurrentUser($excludeCurrentUser, $emailAddress, $owner)) {
                     return;
                 }
                 $ownerName = $this->entityNameResolver->getName($owner);
                 if (!empty($ownerName)) {
                     $emailAddress = $this->emailAddressHelper->buildFullEmailAddress($emailAddress, $ownerName);
                     return;
                 }
             }
         }
         $repo = $this->emailAddressManager->getEmailAddressRepository($this->entityManager);
         $emailAddressObj = $repo->findOneBy(array('email' => $emailAddress));
         if ($emailAddressObj) {
             $owner = $emailAddressObj->getOwner();
             if ($owner) {
                 if ($this->doExcludeCurrentUser($excludeCurrentUser, $emailAddress, $owner)) {
                     return;
                 }
                 $ownerName = $this->entityNameResolver->getName($owner);
                 if (!empty($ownerName)) {
                     $emailAddress = $this->emailAddressHelper->buildFullEmailAddress($emailAddress, $ownerName);
                 }
             }
         }
     }
 }
예제 #2
0
 /**
  * @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
 /**
  * @dataProvider isFullEmailAddressProvider
  */
 public function testIsFullEmailAddress($emailAddress, $isFull)
 {
     $this->assertEquals($isFull, $this->helper->isFullEmailAddress($emailAddress));
 }