I want to test if an object is deleted after a calling to my function executeDelete in order to send to the user an error if the object is still in my database.
if ($logement->isDeleted()) {
$this->getUser()->setFlash('notice', 'Suppression du logement effectuée');
}
else {
$this->getUser()->setFlash('error', 'Erreur lors de la suppression du logement');
}
But I have an error :
Unknown method Logement::isDeleted
I don’t find how to use this method, and I think it’s the problem I have.
You might have to show us more code… But basically your method does not exist, and you would have to create it.
I assume you’re using Doctrine. Assuming that you are deleting the record like so:
Doesn’t the delete method return a boolean to indicate success/failure? So you could simply do the following:
EDIT
If you wanted to implement a
isDeleted()method you could use thepostDelete()hook. In your model class:Then you can do this: