/** * {@inheritdoc} */ public function getRecipients(EmailRecipientsProviderArgs $args) { if (!$args->getRelatedEntity()) { return []; } return EmailRecipientsHelper::filterRecipients($args, $this->relatedEmailsProvider->getRecipients($args->getRelatedEntity(), 2, false, $args->getOrganization())); }
/** * @return array */ protected function createChoices() { $user = $this->securityFacade->getLoggedUser(); if (!$user instanceof User) { return []; } $emails = array_merge(array_values($this->relatedEmailsProvider->getEmails($user, 1, true)), $this->mailboxManager->findAvailableMailboxEmails($user, $this->securityFacade->getOrganization())); return array_combine($emails, $emails); }
/** * @return array */ protected function createChoices() { $user = $this->securityFacade->getLoggedUser(); if (!$user instanceof User) { return []; } $emails = array_values($this->relatedEmailsProvider->getEmails($user, 1, true)); return array_combine($emails, $emails); }
/** * Gets the email address of the given object * * @param object $object * @return string The email address or empty string if the object has no email */ public function getEmail($object) { $result = $this->emailHolderHelper->getEmail($object); if (!$result) { $emails = $this->relatedEmailsProvider->getEmails($object); $result = reset($emails); } return $result ?: ''; }
/** * {@inheritdoc} */ public function getRecipients(EmailRecipientsProviderArgs $args) { if (!$args->getRelatedEntity() instanceof Account) { return []; } $customers = $this->getCustomerRepository()->findBy(['account' => $args->getRelatedEntity()]); $recipients = []; foreach ($customers as $customer) { $recipients = array_merge($recipients, EmailRecipientsHelper::filterRecipients($args, $this->relatedEmailsProvider->getRecipients($customer, 2, false, $args->getOrganization()))); } return $recipients; }
/** * {@inheritdoc} */ public function getRecipients(EmailRecipientsProviderArgs $args) { if (null === ($user = $this->securityFacade->getLoggedUser())) { return []; } $userEmailAddresses = array_keys($this->relatedEmailsProvider->getEmails($user, 1, true)); $recipientsQb = $this->getEmailRecipientRepository()->getEmailsUsedInLast30DaysQb($userEmailAddresses, [], $args->getQuery())->setMaxResults($args->getLimit()); $emails = $this->emailsFromResult($this->aclHelper->apply($recipientsQb)->getResult()); $result = []; foreach ($emails as $email => $name) { $owner = $this->emailOwnerProvider->findEmailOwner($this->registry->getManager(), $email); if (!$this->emailRecipientsHelper->isObjectAllowed($args, $owner)) { continue; } $result[] = new Recipient($email, $name, $this->createRecipientEntity($owner)); } return $result; }
/** * {@inheritdoc} */ public function getRecipients(EmailRecipientsProviderArgs $args) { if (!$args->getRelatedEntity()) { return []; } $relatedEntity = $args->getRelatedEntity(); $relatedEntityClass = ClassUtils::getClass($relatedEntity); $em = $this->registry->getManagerForClass($relatedEntityClass); $metadata = $em->getClassMetadata($relatedEntityClass); $idNames = $metadata->getIdentifierFieldNames(); if (count($idNames) !== 1) { return []; } $propertyAccessor = PropertyAccess::createPropertyAccessor(); $relatedEntityId = $propertyAccessor->getValue($relatedEntity, $idNames[0]); $recipients = []; $activities = $this->activityManager->getActivities($relatedEntityClass); $activityListQb = $this->createActivityListQb($relatedEntityClass, $relatedEntityId); $activityListDql = $activityListQb->getQuery()->getDQL(); $limit = $args->getLimit(); $activityKeys = array_keys($activities); foreach ($activityKeys as $class) { $qb = $this->getRepository($class)->createQueryBuilder('e'); $qb->andWhere($qb->expr()->exists($activityListDql))->setParameter('related_activity_class', $class); foreach ($activityListQb->getParameters() as $param) { $qb->setParameter($param->getName(), $param->getValue(), $param->getType()); } $iterator = new BufferedQueryResultIterator($qb); $iterator->setBufferSize($limit); foreach ($iterator as $entity) { $recipients = array_merge($recipients, EmailRecipientsHelper::filterRecipients($args, $this->relatedEmailsProvider->getRecipients($entity, 2, false, $args->getOrganization()))); $limit -= count($recipients); if ($limit <= 0) { break 2; } } } return $recipients; }