cakephp3 afterSave回调错误

时间:2014-08-31 04:26:55

标签: cakephp cakephp-3.0

每当创建新实体时,都会发生以下错误。

Warning (4096): Argument 3 passed to App\Model\Table\AccountsTable::afterSave() must be of the type array, object given, called in D:\Xampp\htdocs\vendor\cakephp\cakephp\src\Event\EventManager.php on line 268 and defined [APP/Model\Table\AccountsTable.php, line 18]

在模型中保存代码

public function afterSave(Event $event, Entity $entity, array $options) {

}

任何人都知道这里发生了什么?

2 个答案:

答案 0 :(得分:1)

我找到了答案。这里应该是CakePHP文档错误。希望它可以帮助某人。点击此处:http://book.cakephp.org/3.0/en/orm/table-objects.html#Cake\ORM\Table::afterSave

public function afterSave(Event $event, Entity $entity, $options) {
}

答案 1 :(得分:0)

添加此行use ArrayObject;