本文整理汇总了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);
}
示例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());
}
示例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));
}
示例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;
}
示例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);
}
示例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);
}
示例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));
}
示例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));
}
示例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());
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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();
}
示例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();
}
示例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));
}
}
}
}