Closed Regaez closed 4 years ago
Additionally, we should also create a new docs/EVENTS.md
file afterwards that explains the presence of custom events. This should include a list each of the event and its parameters so that others can easily refer to this if they want to develop some third party plugins which integrate with the API.
The API could trigger custom events, such as:
onApiPageGet
onApiPageCreate
onApiPageUpdate
onApiPageDelete
onApiUserCreate
onApiUnauthorisedRequest
... etc
These could be very useful to allow easy communication back to
Grav\Plugin\GravApi
, in order to trigger some specific plugin actions after an Api event. Perhaps even for external plugins to hook into, such as the Admin plugin exposes, to allow 3rd party extensions over the API.For example,
onApiPageGet
might be a useful hook if you wanted to add a tracking plugin to monitor API traffic, or maybeonApiPageUpdate
if you want to bust the cache when a page is updated.At the moment, the API handles the request and then the plugin immediately calls exit, stopping any further execution by Grav. This would probably need to change, to allow any other plugins to tap into the custom events.