本文整理汇总了PHP中Message::getBody方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::getBody方法的具体用法?PHP Message::getBody怎么用?PHP Message::getBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message::getBody方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: receivePublishedMessage
/**
* @param Message $message
*/
public function receivePublishedMessage(Message $message)
{
$topic = $message->getTopic();
$body = $message->getBody();
foreach ($this->subscribers[$topic] as $subscriber) {
/** @var $subscriber Subscriber */
$subscriber->receiveMessage($topic, $body);
}
}
示例2: htmlspecialchars
?>
</from>
<to><?php
echo htmlspecialchars($message->getTo());
?>
</to>
<cc><?php
echo htmlspecialchars($message->getCc());
?>
</cc>
<subject><?php
echo htmlspecialchars($message->getSubject());
?>
</subject>
<body><?php
echo htmlspecialchars($message->getBody());
?>
</body>
</data>
</instance>
<submission id="compose" resource="composemessage.php"
method="urlencoded-post" />
</model>
</models>
<page-header>
<tabs ref="selected-tab">
<tab id='read'>
<label>Messages</label>
<load-page event="activate" page="index.php" />
</tab>
<tab id='write'>
示例3: testGetBody
/**
* Tests Message->getBody()
*/
public function testGetBody()
{
$this->assertEquals('BODY', $this->Message->getBody());
}
示例4: buildIncomingStream
/**
* @coroutine
*
* @param \Icicle\Http\Message\Message $message
* @param float|int $timeout
*
* @return \Generator
*
* @resolve \Icicle\Http\Message\Message
*
* @throws \Icicle\Http\Exception\MessageException
*/
private function buildIncomingStream(Message $message, float $timeout = 0) : \Generator
{
$body = $message->getBody();
if ($body instanceof SeekableStream && $body->isOpen()) {
yield from $body->seek(0);
}
if (!$body->isReadable()) {
return $message;
}
if (strtolower($message->getHeader('Transfer-Encoding') === 'chunked')) {
$stream = new ChunkedDecoder($this->hwm);
$coroutine = new Coroutine(Stream\pipe($body, $stream, true, 0, null, $timeout));
$coroutine->done(null, [$stream, 'close']);
$message = $message->withBody($stream);
} elseif ($message->hasHeader('Content-Length')) {
$length = (int) $message->getHeader('Content-Length');
if (0 > $length) {
throw new MessageException(Response::BAD_REQUEST, 'Content-Length header invalid.');
}
$stream = new MemoryStream($this->hwm);
if (0 === $length) {
yield from $stream->end();
} else {
$coroutine = new Coroutine(Stream\pipe($body, $stream, true, $length, null, $timeout));
$coroutine->done(null, [$stream, 'close']);
}
$message = $message->withBody($stream);
} elseif ($message instanceof Request) {
switch ($message->getMethod()) {
case 'POST':
case 'PUT':
// Post and put messages must have content length or be transfer encoded.
throw new MessageException(Response::LENGTH_REQUIRED, 'Content-Length header required.');
default:
// Assume 0 length body.
$stream = new MemoryStream();
yield from $stream->end();
// Creates empty request body.
return $message->withBody($stream);
}
} elseif (strtolower($message->getHeader('Connection')) !== 'close') {
throw new MessageException(Response::LENGTH_REQUIRED, 'Content-Length header required.');
}
$contentEncoding = strtolower($message->getHeader('Content-Encoding'));
switch ($contentEncoding) {
case 'deflate':
$stream = new ZlibDecoder(ZlibDecoder::DEFLATE, $this->hwm);
break;
case 'gzip':
$stream = new ZlibDecoder(ZlibDecoder::GZIP, $this->hwm);
break;
case '':
// No content encoding.
return $message;
default:
throw new MessageException(Response::BAD_REQUEST, sprintf('Unsupported content encoding received: %s', $contentEncoding));
}
$coroutine = new Coroutine(Stream\pipe($message->getBody(), $stream, true, 0, null, $timeout));
$coroutine->done(null, [$stream, 'close']);
return $message->withBody($stream);
}
示例5: testSetBody
/**
* Tests Message->setBody()
*/
public function testSetBody()
{
$this->message->setBody('body');
$this->assertEquals('body', $this->message->getBody());
}
示例6: send
/** @override */
public function send(Message $email)
{
return $this->send_($email->getFrom(), $email->getTo(), $email->getSubject(), $email->getBody());
}
示例7: sendSimpleMessage
/**
* function sendSimpleMessage
* primary function for sending messages via array
*
* @return void
* @author Sean Grove
**/
public static function sendSimpleMessage($messageArray, $options = null)
{
// TODO: allow an email copy of the message to be sent out
sfContext::getInstance()->getLogger()->log("message:" . print_r($messageArray, true));
sfContext::getInstance()->getLogger()->log("options:" . print_r($options, true));
if (!isset($messageArray["message_type"])) {
$messageArray["message_type"] = 1;
}
sfContext::getInstance()->getLogger()->log('sending Message, owner sender');
$message = new Message();
$message->setSenderId($messageArray["from"]);
sfContext::getInstance()->getLogger()->log('set from: ' . $messageArray["from"]);
$message->setOwnerId($messageArray["owner"]);
$message->setRecipientId($messageArray["to"]);
$message->setParentId($messageArray["parent"]);
$message->setSubject($messageArray["subject"]);
$message->setBody($messageArray["text"]);
$message->setHtmlBody('me');
$message->setFolder($messageArray["folder"]);
$message->setMessageType($messageArray["message_type"]);
$message->save();
if ($message->getMessageType() == 21) {
EventUserPeer::addUser($message->getUuid(), $options["event_id"], $messageArray["from"], $options["points"], $options["comment"], $options["status"]);
}
if (isset($options["copyTo"]) && $options["copyTo"] == "sent") {
sfContext::getInstance()->getLogger()->log('sending Message, owner recipient');
$message2 = array();
$message2["from"] = $messageArray["from"];
$message2["owner"] = $messageArray["from"];
$message2["to"] = $messageArray["to"];
$message2["parent"] = $messageArray["parent"];
$message2["subject"] = $messageArray["subject"];
$message2["text"] = $messageArray["text"];
$message2["folder"] = "sent";
self::sendSimpleMessage($message2);
}
if (!isset($options["notify"]) || $options["notify"] == true) {
$sender = $message->getsfGuardUserRelatedBySenderId()->getProfile();
$recipient = $message->getsfGuardUserRelatedByRecipientId()->getProfile();
$text = '"' . $message->getSubject() . ' :: ' . $message->getBody() . '"';
$notification = 'New message from ' . $sender->getFullName() . ' on Cothink! ';
$notification .= $text;
$recipient->notify($notification);
}
sfContext::getInstance()->getLogger()->log('message sent');
}
示例8: testSettersAndGetters
/**
* Tests the setters and getters.
*/
public function testSettersAndGetters()
{
// create a message with minimum constructor args
$message = new Message(Message::NORMAL);
// Set remainder via setters
$message->setHeader((object) array('testProp' => 'testval'));
$message->setBody(simplexml_load_string('<testMessage testAtt="Hello" testAtt2="world"/>'));
$message->setPriority(Message::PRIORITY_LOW);
// test assertions
$this->assertTrue($message instanceof Message, "Expecting \$message is Message");
$this->assertTrue($message->getType() == Message::NORMAL, "Expecting \$message->getType() == Message::NORMAL");
$this->assertTrue($message->getHeader()->testProp == 'testval', "Expecting \$message->getHeader()->testProp == 'testval'");
$this->assertTrue($message->getBody()->attributes()->testAtt == 'Hello', "Expecting \$message->getBody()->attributes()->testAtt == 'Hello'");
$this->assertTrue($message->getPriority() == Message::PRIORITY_LOW, "Expecting \$message->getPriority() == Message::PRIORITY_LOW");
}