当前位置: 首页>>代码示例>>PHP>>正文


PHP Conversation::sendMessage方法代码示例

本文整理汇总了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);
 }
开发者ID:allejo,项目名称:bzion,代码行数:28,代码来源:MessageController.php


注:本文中的Conversation::sendMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。