本文整理汇总了PHP中Swift_Events_SendEvent::getMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Swift_Events_SendEvent::getMessage方法的具体用法?PHP Swift_Events_SendEvent::getMessage怎么用?PHP Swift_Events_SendEvent::getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Swift_Events_SendEvent
的用法示例。
在下文中一共展示了Swift_Events_SendEvent::getMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeSendPerformed
/**
* @param \Swift_Events_SendEvent $evt
*/
public function beforeSendPerformed(\Swift_Events_SendEvent $evt)
{
$message = $evt->getMessage();
$this->convert($message);
$children = $message->getChildren();
array_walk($children, array($this, 'convert'));
}
示例2: beforeSendPerformed
/**
* Invoked immediately before the Message is sent.
*
* @param Swift_Events_SendEvent $evt
*/
public function beforeSendPerformed(Swift_Events_SendEvent $evt)
{
$this->messages[] = $message = clone $evt->getMessage();
$to = null === $message->getTo() ? '' : implode(', ', array_keys($message->getTo()));
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Sending email "%s" to "%s"', $message->getSubject(), $to))));
}
示例3: sendPerformed
public function sendPerformed(\Swift_Events_SendEvent $event)
{
// If this was sent through SES, retrieve the data
if (config('mail.driver') == 'ses') {
$message = $event->getMessage();
$this->updateSesMessageId($message);
}
}
示例4: sendPerformed
/**
* Gestion des messages apres leur envoi
* @param Swift_Events_SendEvent $event [description]
* @return [type] [description]
*/
public function sendPerformed(\Swift_Events_SendEvent $evt)
{
if ($evt->getResult() === \Swift_Events_SendEvent::RESULT_SUCCESS && $this->enabled == true) {
// Création de l'activity
$activity = $this->createActivity($evt->getMessage());
$this->dm->persist($activity);
$this->dm->flush();
}
}
示例5: beforeSendPerformed
/**
* {@inheritdoc}
*/
public function beforeSendPerformed(\Swift_Events_SendEvent $event)
{
$message = $event->getMessage();
if (!$this->isEnabled() || !$message instanceof \Swift_Message || in_array($message->getId(), $this->performed)) {
return;
}
$signature = new \Swift_Signers_DKIMSigner($this->getPrivateKey(), $this->domain, $this->selector);
$message->attachSigner($signature);
$this->performed[] = $message->getId();
}
示例6: sendPerformed
/**
* Invoked immediately after the Message is sent.
*
* @param Swift_Events_SendEvent $evt
*/
public function sendPerformed(Swift_Events_SendEvent $evt)
{
$message = $evt->getMessage();
// restore original headers
$headers = $message->getHeaders();
if ($headers->has('X-Swift-Return-Path')) {
$message->setReturnPath($headers->get('X-Swift-Return-Path')->getAddress());
$headers->removeAll('X-Swift-Return-Path');
}
}
示例7: beforeSendPerformed
/**
* @param \Swift_Events_SendEvent $evt
*/
public function beforeSendPerformed(\Swift_Events_SendEvent $evt)
{
$message = $evt->getMessage();
if ($message->getContentType() === 'text/html' || $message->getContentType() === 'multipart/alternative' && $message->getBody() || $message->getContentType() === 'multipart/mixed' && $message->getBody()) {
$message->setBody($this->converter->convert($message->getBody(), $this->css));
}
foreach ($message->getChildren() as $part) {
if (strpos($part->getContentType(), 'text/html') === 0) {
$part->setBody($this->converter->convert($part->getBody(), $this->css));
}
}
}
示例8: sendPerformed
/**
* Invoked immediately after the Message is sent.
*
* @param \Swift_Events_SendEvent $evt
*/
public function sendPerformed(\Swift_Events_SendEvent $evt)
{
$result = $evt->getResult();
$failed_recipients = $evt->getFailedRecipients();
$message = $evt->getMessage();
if ($result === \Swift_Events_SendEvent::RESULT_SUCCESS) {
$level = $this->levels['sendPerformed.SUCCESS'];
} else {
$level = $this->levels['sendPerformed.NOT_SUCCESS'];
}
$this->log($level, 'MESSAGE (sendPerformed): ', array('result' => $result, 'failed_recipients' => $failed_recipients, 'message' => $message->toString()));
}
示例9: beforeSendPerformed
/**
* Inline the CSS before an email is sent.
*
* @param \Swift_Events_SendEvent $evt
*/
public function beforeSendPerformed(\Swift_Events_SendEvent $evt)
{
$message = $evt->getMessage();
$properTypes = ['text/html', 'multipart/alternative', 'multipart/mixed'];
if ($message->getBody() && in_array($message->getContentType(), $properTypes)) {
$this->inliner->setHtml($message->getBody());
$message->setBody($this->inliner->emogrify());
}
foreach ($message->getChildren() as $part) {
if (strpos($part->getContentType(), 'text/html') === 0) {
$this->inliner->setHtml($part->getBody());
$message->setBody($this->inliner->emogrify());
}
}
}
示例10: beforeSendPerformed
/**
* @param Swift_Events_SendEvent $evt
*/
public function beforeSendPerformed(\Swift_Events_SendEvent $evt)
{
$message = $evt->getMessage();
$converter = new CssToInlineStyles();
$converter->setEncoding($message->getCharset());
$converter->setUseInlineStylesBlock();
$converter->setCleanup();
if ($message->getContentType() === 'text/html' || $message->getContentType() === 'multipart/alternative' && $message->getBody() || $message->getContentType() === 'multipart/mixed' && $message->getBody()) {
$converter->setHTML($message->getBody());
$message->setBody($converter->convert());
}
foreach ($message->getChildren() as $part) {
if (strpos($part->getContentType(), 'text/html') === 0) {
$converter->setHTML($part->getBody());
$part->setBody($converter->convert());
}
}
}
示例11: beforeSendPerformed
/**
* {@inheritdoc}
*/
public function beforeSendPerformed(\Swift_Events_SendEvent $event)
{
$message = $event->getMessage();
if (!$this->isEnabled() || !$message instanceof \Swift_Message || in_array($message->getId(), $this->performed) || null === $message->getBody()) {
return;
}
$dom = new \DOMDocument('1.0', 'utf-8');
$internalErrors = libxml_use_internal_errors(true);
$dom->loadHTML($message->getBody());
libxml_use_internal_errors($internalErrors);
$xpath = new \DOMXPath($dom);
$nodes = $xpath->query('//img/@src');
$images = array();
foreach ($nodes as $node) {
$this->embedImage($message, $node, $images);
}
$message->setBody($dom->saveHTML(), 'text/html');
$this->performed[] = $message->getId();
}
示例12: sendPerformed
/**
* Invoked immediately after the Message is sent.
*
* @param Swift_Events_SendEvent $evt
*/
public function sendPerformed(Swift_Events_SendEvent $evt)
{
$message = $evt->getMessage();
$message->toByteStream($this);
}
示例13: beforeSendPerformed
/**
* Invoked immediately before the Message is sent.
*
* @param \Swift_Events_SendEvent $event
*/
public function beforeSendPerformed(\Swift_Events_SendEvent $event)
{
$event->getMessage()->setFrom($this->address, $this->name);
}
示例14: beforeSendPerformed
/**
* Called just before Swift sends a message.
* We perform operations on the message here.
* @param Swift_Events_SendEvent The event object for sending a message
*/
public function beforeSendPerformed(Swift_Events_SendEvent $e)
{
$message = $e->getMessage();
$this->recursiveRestore($message, $this->store);
//3.3.3 bugfix
$recipients = $e->getRecipients();
$to = array_keys($recipients->getTo());
if (count($to) > 0) {
$to = $to[0];
} else {
return;
}
$replacements = (array) $this->replacements->getReplacementsFor($to);
$this->store = array("headers" => array(), "body" => false, "children" => array());
$this->recursiveReplace($message, $replacements, $this->store);
}
示例15: testMultiArray
public function testMultiArray()
{
$transport = \Swift_MailTransport::newInstance();
$message = \Swift_Message::newInstance('Wonderful Subject')->setFrom(array('john@doe.com' => 'John Doe'))->setTo(array('info@rollerscapes.net', 'webmaster@google.nl'));
$message->setBody('Here is the message itself');
$oLooseAttachment = \Swift_Attachment::newInstance('this an none-test document', 'Invoice-2011-848.txt', 'plain/text');
$message->attach($oLooseAttachment);
$sendEvent = new \Swift_Events_SendEvent($transport, $message);
$replacements = array('info@rollerscapes.net' => array(\Swift_Attachment::newInstance('this an test document', 'Invoice-2011-4342.txt', 'plain/text')), 'webmaster@google.nl' => array(\Swift_Attachment::newInstance('this an none-test document', 'Invoice-2011-8480.txt', 'plain/text'), array('data' => 'this an none-test2 document', 'filename' => 'Invoice-2011-8580.txt')));
$mailDecorator = new AttachmentDecorator($replacements);
foreach ($replacements as $email => $msgReplacements) {
$sendEvent->getMessage()->setTo($email);
$mailDecorator->beforeSendPerformed($sendEvent);
$message = $sendEvent->getMessage();
$this->assertEquals('Here is the message itself', trim($message->getBody()));
$children = (array) $message->getChildren();
$attachments = array();
foreach ($children as $child) {
if (\Swift_Mime_MimeEntity::LEVEL_MIXED === $child->getNestingLevel() && 'Invoice-2011-848.txt' == $child->getFilename()) {
continue;
}
if (\Swift_Mime_MimeEntity::LEVEL_MIXED === $child->getNestingLevel()) {
$attachments[] = $child;
}
}
$this->assertEquals($attachments, $attachments);
$mailDecorator->sendPerformed($sendEvent);
$children = (array) $message->getChildren();
// Check to make sure the original Attachment is still there
foreach ($children as $child) {
if (\Swift_Mime_MimeEntity::LEVEL_MIXED === $child->getNestingLevel()) {
$this->assertEquals($oLooseAttachment->toString(), $child->toString());
}
}
}
}