本文整理汇总了PHP中Oro\Bundle\EmailBundle\Entity\Email::setEmailBody方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::setEmailBody方法的具体用法?PHP Email::setEmailBody怎么用?PHP Email::setEmailBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\EmailBundle\Entity\Email
的用法示例。
在下文中一共展示了Email::setEmailBody方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
示例2: testEnsureEmailBodyCachedForAlreadyCached
public function testEnsureEmailBodyCachedForAlreadyCached()
{
$email = new Email();
$email->setEmailBody(new EmailBody());
$this->emailBodySynchronizer->expects($this->never())->method('syncOneEmailBody');
$this->manager->ensureEmailBodyCached($email);
}
示例3: testSyncOneEmailBodyForAlreadyCached
public function testSyncOneEmailBodyForAlreadyCached()
{
$email = new Email();
$email->setEmailBody(new EmailBody());
$this->selector->expects($this->never())->method('select');
$this->synchronizer->syncOneEmailBody($email);
}
示例4: testEmailBodyGetterAndSetter
public function testEmailBodyGetterAndSetter()
{
$emailBody = $this->getMock('Oro\\Bundle\\EmailBundle\\Entity\\EmailBody');
$entity = new Email();
$entity->setEmailBody($emailBody);
$this->assertTrue($emailBody === $entity->getEmailBody());
}
示例5: inapplicableEmailsProvider
public function inapplicableEmailsProvider()
{
$date = new \DateTime('now', new \DateTimeZone('UTC'));
$oldEmailDate = new \DateTime('now', new \DateTimeZone('UTC'));
$oldEmailDate->sub(\DateInterval::createFromDateString('2 day'));
$applicableSubjectsAndBodies = [['not empty subject', 'This is email body with offer, sale and won words.', $date], [null, 'This email has nothing.', $date], [null, 'This is email body with sale and won words.', $oldEmailDate]];
$data = array_map(function ($subjectAndBody) {
list($subject, $bodyContent, $sentAt) = $subjectAndBody;
$body = new EmailBody();
$body->setBodyContent($bodyContent);
$email = new Email();
$email->setSubject($subject);
$email->setEmailBody($body);
$email->setSentAt($sentAt);
return [$email];
}, $applicableSubjectsAndBodies);
return $data;
}
示例6: processBodyType
/**
* @param Email $email
* @param string $type
*/
protected function processBodyType(Email $email, $type)
{
$body = $email->getEmailBody();
if ($body) {
if ($email->getId()) {
if ($body->getBodyIsText() !== ($type === true)) {
throw $this->createInvalidPropertyException('Body Type', $this->emailBodyTypeTransformer->transform($body->getBodyIsText()), $this->emailBodyTypeTransformer->transform($type));
}
} else {
$body->setBodyIsText($type === true);
}
} else {
$email->setEmailBody($this->emailEntityBuilder->body('', $type !== true, true));
}
}