简体   繁体   English

FOSMessageBundle发送消息错误

[英]FOSMessageBundle sending a message error

i would like to send a message via FOSMessageBundle so i create a controller witch contain a method named send, after that i got an error in this instuction : 我想通过FOSMessageBundle发送消息,所以我创建了一个包含名为send的方法的控制器,之后我在此检查中出错:

$sender = $this->get('fos_message.sender');
$sender->send($message);

the error message is : 错误消息是:

Catchable Fatal Error: Argument 1 passed to FOS\MessageBundle\Sender\Sender::send() must implement interface FOS\MessageBundle\Model\MessageInterface, instance of FOS\MessageBundle\MessageBuilder\NewThreadMessageBuilder given, called in /projet/pivotalpartnersbo/src/Application/Sonata/MessageBundle/Controller/MessageController.php on line 32

The message must me created. 该消息必须由我创建。

Something like $message = $builder->newThread(); $message = $builder->newThread(); or $message = $builder->reply($thread); $message = $builder->reply($thread);

While you apparently have just $message = $builder; 虽然您显然只有$message = $builder;

thanks qooplmao and yonel i just find the mistake, that i forget to extend the BaseMessage in the class of $message object. 谢谢qooplmaoyonel,我只是发现了错误,我忘记在$ message对象的类中扩展BaseMessage了。 BaseMessage implement the MessageInterface. BaseMessage实现MessageInterface。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM