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

I get this error when i load one controller but it is not present in any other controller.

And this is the only delete action in the Term controller

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 is Termscontroller

zamil
  • 1,920
  • 4
  • 17
  • 32
  • The message is telling you what the problem is! You’ve obviously declared `beforeDelete()` in a model you’re loading (either Car or Term looking at your controller code) that has different parameters to the base model’s `beforeDelete()` method. – Martin Bean Jul 19 '13 at 11:59
  • @MartinBean: there is no beforeDelete() in Term model file,sorry car was a typo – zamil Jul 19 '13 at 12:13

1 Answers1

3

Fix the declaration of the behavior method. If possible, also submit the correct version back to the maintainer of the plugin (if that is not you).

As already mentioned by the error message, it should be:

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

Yours is probably just

public function beforeDelete(Model $model) {}

etc.

mark
  • 21,691
  • 3
  • 49
  • 71
  • thanks it fixed it. Since i am pretty new to cake and am working on an existing code base written by somebody else.But why this error is not coming in other controllers? – zamil Jul 19 '13 at 12:15
  • You are not using the behavior there (using = loading). – mark Jul 19 '13 at 12:17