当前位置: 首页>>代码示例>>PHP>>正文


PHP Entity\Email类代码示例

本文整理汇总了PHP中Oro\Bundle\EmailBundle\Entity\Email的典型用法代码示例。如果您正苦于以下问题:PHP Email类的具体用法?PHP Email怎么用?PHP Email使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Email类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testEnsureEmailBodyCachedForAlreadyCached

 public function testEnsureEmailBodyCachedForAlreadyCached()
 {
     $email = new Email();
     $email->setEmailBody(new EmailBody());
     $this->emailBodySynchronizer->expects($this->never())->method('syncOneEmailBody');
     $this->manager->ensureEmailBodyCached($email);
 }
开发者ID:snorchel,项目名称:platform,代码行数:7,代码来源:EmailCacheManagerTest.php

示例2: testReplace

 /**
  * @dataProvider replaceDataProvider
  * @param       $bodyTemplate
  * @param array $attachments
  */
 public function testReplace($bodyTemplate, array $attachments)
 {
     $email = new Email();
     $emailBody = new EmailBody();
     $replacements = [];
     $contentIds = [];
     foreach ($attachments as $attachmentData) {
         $attachment = new EmailAttachment();
         $emailAttachmentContent = new EmailAttachmentContent();
         $emailAttachmentContent->setContent($attachmentData['content'])->setContentTransferEncoding($attachmentData['transfer_encoding']);
         $attachment->setEmbeddedContentId($attachmentData['content_id'])->setContentType($attachmentData['type'])->setContent($emailAttachmentContent);
         $emailBody->addAttachment($attachment);
         $cid = 'cid:' . $attachmentData['content_id'];
         $contentIds[] = $cid;
         if ($attachmentData['replace']) {
             $replacements[] = sprintf('data:%s;base64,%s', $attachmentData['type'], $attachmentData['content']);
         } else {
             $replacements[] = $cid;
         }
     }
     $emailBody->setBodyContent(vsprintf($bodyTemplate, $contentIds));
     $email->setEmailBody($emailBody);
     $event = new EmailBodyLoaded($email);
     $this->listener->replace($event);
     $this->assertEquals($email, $event->getEmail());
     $this->assertEquals(vsprintf($bodyTemplate, $replacements), $event->getEmail()->getEmailBody()->getBodyContent());
 }
开发者ID:ramunasd,项目名称:platform,代码行数:32,代码来源:ReplaceEmbeddedAttachmentsListenerTest.php

示例3: ensureEmailBodyCached

 /**
  * Check that email body is cached.
  * If do not, load it using appropriate email extension add it to a cache.
  *
  * @param Email $email
  *
  * @throws LoadEmailBodyException if a body of the given email cannot be loaded
  */
 public function ensureEmailBodyCached(Email $email)
 {
     if ($email->getEmailBody() === null) {
         // body loader can load email from any folder
         // todo: refactor to use correct emailuser and origin
         // to use active origin and get correct folder from this origin
         $emailUser = $email->getEmailUsers()->first();
         $folder = $emailUser->getFolders()->first();
         $origin = $emailUser->getOrigin();
         if (!$origin) {
             throw new LoadEmailBodyFailedException($email);
         }
         $loader = $this->selector->select($origin);
         try {
             $emailBody = $loader->loadEmailBody($folder, $email, $this->em);
         } catch (LoadEmailBodyException $loadEx) {
             $this->logger->notice(sprintf('Load email body failed. Email id: %d. Error: %s', $email->getId(), $loadEx->getMessage()), ['exception' => $loadEx]);
             throw $loadEx;
         } catch (\Exception $ex) {
             $this->logger->warning(sprintf('Load email body failed. Email id: %d. Error: %s.', $email->getId(), $ex->getMessage()), ['exception' => $ex]);
             throw new LoadEmailBodyFailedException($email, $ex);
         }
         $email->setEmailBody($emailBody);
         $this->em->persist($email);
         $this->em->flush();
         $event = new EmailBodyAdded($email);
         $this->eventDispatcher->dispatch(EmailBodyAdded::NAME, $event);
     }
     $this->eventDispatcher->dispatch(EmailBodyLoaded::NAME, new EmailBodyLoaded($email));
 }
开发者ID:Maksold,项目名称:platform,代码行数:38,代码来源:EmailCacheManager.php

示例4: getEmailContext

 /**
  * Returns the context for the given email
  *
  * @param Email $email
  *
  * @return array
  */
 public function getEmailContext(Email $email)
 {
     $criteria = Criteria::create();
     $criteria->andWhere(Criteria::expr()->eq('id', $email->getId()));
     $qb = $this->activityManager->getActivityTargetsQueryBuilder($this->class, $criteria);
     if (null === $qb) {
         return [];
     }
     $result = $qb->getQuery()->getResult();
     if (empty($result)) {
         return $result;
     }
     $currentUser = $this->securityFacade->getLoggedUser();
     $currentUserClass = ClassUtils::getClass($currentUser);
     $currentUserId = $currentUser->getId();
     $result = array_values(array_filter($result, function ($item) use($currentUserClass, $currentUserId) {
         return !($item['entity'] === $currentUserClass && $item['id'] == $currentUserId);
     }));
     foreach ($result as &$item) {
         $route = $this->configManager->getEntityMetadata($item['entity'])->getRoute();
         $item['entityId'] = $email->getId();
         $item['targetId'] = $item['id'];
         $item['targetClassName'] = $this->entityClassNameHelper->getUrlSafeClassName($item['entity']);
         $item['icon'] = $this->configManager->getProvider('entity')->getConfig($item['entity'])->get('icon');
         $item['link'] = $route ? $this->router->generate($route, ['id' => $item['id']]) : null;
         unset($item['id'], $item['entity']);
     }
     return $result;
 }
开发者ID:nmallare,项目名称:platform,代码行数:36,代码来源:EmailApiEntityManager.php

示例5: setFlags

 /**
  * (@inherit)
  */
 public function setFlags(EmailFolder $folder, Email $email, $flags)
 {
     $repoImapEmail = $this->em->getRepository('OroImapBundle:ImapEmail');
     $uid = $repoImapEmail->getUid($folder->getId(), $email->getId());
     $this->connector->selectFolder($folder->getFullName());
     $this->connector->setFlags($uid, $flags);
 }
开发者ID:Maksold,项目名称:platform,代码行数:10,代码来源:ImapEmailFlagManager.php

示例6: ensureEmailBodyCached

 /**
  * Check that email body is cached.
  * If do not, load it using appropriate email extension add it to a cache.
  *
  * @param Email $email
  *
  * @throws LoadEmailBodyException if a body of the given email cannot be loaded
  */
 public function ensureEmailBodyCached(Email $email)
 {
     if ($email->getEmailBody() !== null) {
         // The email body is already cached
         return;
     }
     // body loader can load email from any folder
     $folder = $email->getEmailUsers()->first()->getFolder();
     $origin = $folder->getOrigin();
     $loader = $this->selector->select($origin);
     try {
         $emailBody = $loader->loadEmailBody($folder, $email, $this->em);
     } catch (LoadEmailBodyException $loadEx) {
         $this->logger->notice(sprintf('Load email body failed. Email id: %d. Error: %s', $email->getId(), $loadEx->getMessage()), ['exception' => $loadEx]);
         throw $loadEx;
     } catch (\Exception $ex) {
         $this->logger->warning(sprintf('Load email body failed. Email id: %d. Error: %s.', $email->getId(), $ex->getMessage()), ['exception' => $ex]);
         throw new LoadEmailBodyFailedException($email, $ex);
     }
     $email->setEmailBody($emailBody);
     $this->em->persist($email);
     $this->em->flush();
     $event = new EmailBodyAdded($email);
     $this->eventDispatcher->dispatch(EmailBodyAdded::NAME, $event);
 }
开发者ID:EyeOpenServer,项目名称:platform,代码行数:33,代码来源:EmailCacheManager.php

示例7: testGetDate

 public function testGetDate()
 {
     $email = new Email();
     $date = new \DateTime('now', new \DateTimeZone('UTC'));
     $email->setSentAt($date);
     $this->assertSame($date, $this->provider->getDate($email));
 }
开发者ID:rodolfobandeira,项目名称:crm,代码行数:7,代码来源:EmailDirectionProviderTest.php

示例8: ensureEmailBodyCached

 /**
  * Check that email body is cached.
  * If do not, load it using appropriate email extension add it to a cache.
  *
  * @param Email $email
  */
 public function ensureEmailBodyCached(Email $email)
 {
     if ($email->getEmailBody() === null) {
         $this->emailBodySynchronizer->syncOneEmailBody($email);
         $this->em->flush();
     }
     $this->eventDispatcher->dispatch(EmailBodyLoaded::NAME, new EmailBodyLoaded($email));
 }
开发者ID:snorchel,项目名称:platform,代码行数:14,代码来源:EmailCacheManager.php

示例9: testBeforeSave

 public function testBeforeSave()
 {
     $entity = new Email();
     $entity->beforeSave();
     $createdAt = new \DateTime('now', new \DateTimeZone('UTC'));
     $this->assertEquals(Email::NORMAL_IMPORTANCE, $entity->getImportance());
     $this->assertGreaterThanOrEqual($createdAt, $entity->getCreated());
 }
开发者ID:Maksold,项目名称:platform,代码行数:8,代码来源:EmailThreadTest.php

示例10: __construct

 /**
  * @param Email  $email
  * @param \Exception $previous
  */
 public function __construct(Email $email, \Exception $previous = null)
 {
     $message = sprintf('Cannot load a body for "%s" email.', $email->getSubject());
     if ($previous) {
         $message .= sprintf(' Reason: %s.', $previous->getMessage());
     }
     parent::__construct($message, 0, $previous);
 }
开发者ID:Maksold,项目名称:platform,代码行数:12,代码来源:LoadEmailBodyFailedException.php

示例11: addRecipientOwners

 /**
  * @param array $targets
  * @param Email $email
  */
 protected function addRecipientOwners(&$targets, Email $email)
 {
     $recipients = $email->getRecipients();
     foreach ($recipients as $recipient) {
         $owner = $recipient->getEmailAddress()->getOwner();
         if ($owner) {
             $this->addTarget($targets, $owner);
         }
     }
 }
开发者ID:xamin123,项目名称:platform,代码行数:14,代码来源:EmailActivityManager.php

示例12: getFromNameLink

 /**
  * @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;
 }
开发者ID:northdakota,项目名称:platform,代码行数:15,代码来源:EmailNotificationManager.php

示例13: load

 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $fromEmail = new EmailAddressProxy();
     $fromEmail->setEmail(uniqid() . '@gmail.com');
     $email = new Email();
     $email->setSubject(uniqid())->setFromName(uniqid())->setReceivedAt(new \DateTime())->setSentAt(new \DateTime())->setInternalDate(new \DateTime())->setFromEmailAddress($fromEmail)->setMessageId(uniqid());
     $manager->persist($fromEmail);
     $manager->persist($email);
     $manager->flush();
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:13,代码来源:LoadEmails.php

示例14: ensureEmailBodyCached

 /**
  * Check that email body is cached.
  * If do not, load it using appropriate email extension add it to a cache.
  *
  * @param Email $email
  */
 public function ensureEmailBodyCached(Email $email)
 {
     if ($email->getEmailBody() !== null) {
         // The email body is already cached
         return;
     }
     $emailBody = $this->selector->select($email->getFolder()->getOrigin())->loadEmailBody($email, $this->em);
     $email->setEmailBody($emailBody);
     $this->em->persist($email);
     $this->em->flush();
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:17,代码来源:EmailCacheManager.php

示例15: addRecipients

 /**
  * Add recipients to the specified Email object
  *
  * @param Email $obj The Email object recipients is added to
  * @param string $type The recipient type. Can be to, cc or bcc
  * @param string $email The email address, for example: john@example.com or "John Smith" <john@example.com>
  */
 protected function addRecipients(Email $obj, $type, $email)
 {
     if (!empty($email)) {
         if (is_string($email)) {
             $obj->addRecipient($this->recipient($type, $email));
         } elseif (is_array($email) || $email instanceof \Traversable) {
             foreach ($email as $e) {
                 $obj->addRecipient($this->recipient($type, $e));
             }
         }
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:19,代码来源:EmailEntityBuilder.php


注:本文中的Oro\Bundle\EmailBundle\Entity\Email类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。