i have new module with yii who have to check any delete actions to other module how can i use BeforeDelete
in my new module targeting any update in another module ? thank you
i have new module with yii who have to check any delete actions to other module how can i use BeforeDelete
in my new module targeting any update in another module ? thank you
Hi @hazmaniameur, welcome to the forum.
Could you please elaborate your question a little further?
So you have module A and module B. And you want to do something in module A when something is deleted in module B. Am I right?
Hi @softark thank you for your answer,
i have first module named ** Search ** who is is using ElasticSearch (search engine)
and i have a module named ** Posts **, whois in charge to manage posts made by different users.
** without modifing the module Posts **, i whould like to listen to any action delete who is targeting the tables of Posts module **, from the module Search ** module, to ask this module to delete them also from ElasticSearch.
to simply answer to your questions :
thank you for your help
Thank you, I think I understand your requirements.
I would do the following if I were you.
Post
ActiveRecord model, I would customize beforeDelete
method to call some static method of Search
model.Search
model, I would write some static method that would delete certain entries based on the parameters of the method.Post
model itself. I’m not really sure about this point. It depends.Note that ActiveRecord::deleteAll()
method won’t trigger beforeDelete()
. Please check the following section of the guide: https://www.yiiframework.com/doc/guide/2.0/en/db-active-record#ar-life-cycles
P.S.
You can not catch a delete action of Post
in Search
model.