Nathan Payne
Nathan Payne

Reputation: 83

How do I "do something" after delete with Silverstripe

I am Using SilverStripe and have a DataObject lets call it books and I want to be able to process something when the book is deleted from the database.

There is no onAfterDelete method but it does call the onAfterWrite method but I need to be able to tell the difference between an addition and deletion.

Example: When I add a book to the system using the CMS I want to be able to add it to the library and set some other data up. When I delete the book from the system within the CMS I want to be able to remove it from the library and then remove the other data I setup.

Upvotes: 2

Views: 522

Answers (1)

colymba
colymba

Reputation: 2644

Looking at the API for SS 3 there are hooks on DataObject for onBeforeDelete and onAfterDelete http://api.silverstripe.org/3.0/source-class-DataObject.html#962-974

Remember to call parent::onBefore.... and you can do whatever you want there....

Upvotes: 2

Related Questions