在蛋糕php中得到这样的错误

时间:2013-07-19 11:45:45

标签: php cakephp

Declaration of UtilityBehavior::beforeDelete() should be compatible with ModelBehavior::beforeDelete(Model $model, $cascade = true)

当我加载一个控制器时出现此错误,但在任何其他控制器中都没有。

这是Term控制器中唯一的删除操作

public function admin_delete($id = null) {
        if (!$this->request->is('post')) {
            throw new MethodNotAllowedException();
        }
        $this->Term->id = $id;
        if (!$this->Term->exists()) {
            throw new NotFoundException(__('Invalid term'));
        }
        if ($this->Term->delete()) {
            $this->Session->setFlash(__('Term deleted'));
            $this->redirect(array('action' => 'index'));
        }
        $this->Session->setFlash(__('term was not deleted'));
        $this->redirect(array('action' => 'index'));
    }

controller是Termscontroller

1 个答案:

答案 0 :(得分:3)

修复行为方法的声明。如果可能的话,还要将正确的版本提交给插件的维护者(如果不是你的话)。

如错误消息所述,应为

public function beforeDelete(Model $model, $cascade = true) {}

你的可能只是

public function beforeDelete(Model $model) {}