Is anyone able to tell me how to write a function that can intercept the publish command on silverstripe? I want to implement a system where whenever a page change is about to occur, a HTTP call to another system is sent, that will inform the administrator that a page has been changed. I want the system to wait a few minutes then, giving the administrator time to remove the change if it wasn’t authorised.
Share
There’s various event hooks in the
SiteTreeclass which you can use for this purpose.Apply the extension with the following addition to your
mysite/_config.php:You’ll obviously need to implement the
notifyMyAdmin()method to make that HTTP call.In general, I would advise against doing synchronous HTTP calls on user actions though,
since they make your system dependent on the availability of another one. Consider using something like the messagequeue module instead. In terms of “wait a few minutes with publication”: Its not possible to “veto” publications through the extension system.
You could overwrite
SiteTree->doPublish()in your subclass for this purpose, but it would still be a bit of a weird UI pattern for the user. Workflow module plus “Request Publication” plus some cron job to auto-approve them would be more straightforward.