Is there a way from a plugin to trigger an event (say, "OnBeforeDocFormSave") from a plugin? Or to bind to an event, but stop the actual MODx event from happening?
An example would be binding to the Save event, but prevent MODx from saving the resource.
You can trigger an event with $modx->invokeEvent(), but I would hesitate to do that in a plugin unless you're triggering your own custom event, since you're in the middle of another event -- things could get weird.
Some events have a return value that can affect subsequent processing, but most don't. OnDocFormSave does not, but OnBeforeDocFormSave does.
Looking at the code, if your OnBeforeDocFormSave plugin returns false or an array of error messages, the save might be aborted, but I've never tried it.
In a plugin tied to OnDocFormSave, I don't think there's any way to abort the save, but you could delete the resource that's just been saved.
-
☆ A M B ☆
- 24,524 Posts
A plugin can always abort further processing altogether using the PHP exit() function, but that leaves you looking at an empty right section in the page.