本文整理汇总了PHP中Conversation::sendMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Conversation::sendMessage方法的具体用法?PHP Conversation::sendMessage怎么用?PHP Conversation::sendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Conversation
的用法示例。
在下文中一共展示了Conversation::sendMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendMessage
/**
* Sends a message to a conversation
*
* @param Player $from The sender
* @param Conversation $to The conversation that will receive the message
* @param Form $form The message's form
* @param Form $form The form before it handled the request
* @param Form $cloned
* @throws HTTPException Thrown if the user doesn't have the
* SEND_PRIVATE_MSG permission
* @return void
*/
private function sendMessage(Player $from, Conversation $to, &$form, $cloned)
{
if (!$from->hasPermission(Permission::SEND_PRIVATE_MSG)) {
throw new ForbiddenException("You are not allowed to send messages");
}
$message = $form->get('message')->getData();
$message = $to->sendMessage($from, $message);
$this->getFlashBag()->add('success', "Your message was sent successfully");
// Let javascript know the message's ID
$this->attributes->set('id', $message->getId());
// Reset the form
$form = $cloned;
// Notify everyone that we sent a new message
$event = new NewMessageEvent($message, false);
$this->dispatch(Events::MESSAGE_NEW, $event);
}