我目前正在CakePHP2.6上做一个网站。2.我使用一个插件进行评论,如下所示:评论插件。一切正常,直到我尝试向帖子添加评论,然后返回以下错误:
严格(2048):声明的评论::afterSave()应与模型::afterSave兼容($创建,$选项=数组)
[APP/Plugin/Comment/Model/Comment.php,第2行]
我不明白为什么会出现这个错误,以及我如何解决它。
我搜索了已经涵盖的问题,但我不明白应该如何进行。我试了好几次,但都没有成功
我有comment.php:
public function afterSave($created){
if ($created) {
$model = ClassRegistry::init($this->data[$this->alias]['ref']);
// Manual countercache, it's more flexible, no need to add complex relation on Comment Model
if($model->hasField('comment_count')){
$model->id = $this->data[$this->alias]['ref_id'];
$model->saveField('comment_count',$this->find('count',array(
'conditions' => array('ref'=>$this->data[$this->alias]['ref'],'ref_id'=>$this->data[$this->alias]['ref_id'])
)));
}
$this->getEventManager()->dispatch(new CakeEvent('Plugin.Comment.add', $this));
}
}
和评论控制器。php:
$this->Comment->create($this->request->data, true);
我试图做的改变:
$this->Comment->create($this->request->data, true);
要$this-
对不起,但是我不明白我到底要做什么