#Custom API hooks examples?

13 messages · Page 1 of 1 (latest)

kindred knoll
#

Is there any publically available working example of a custom event hook (extension) so I could understand how they work exactly? I need to add more information to the update and delete events, taken from previous revisions. So something resembling that would be ideal, or else anything at all should do.

lusty trout
#

I have a couple of extensions available making use of hooks but not sure how useful those will be for your usecase. Im not completely sure what you mean with "I need to add more information to the update and delete events" but there are examples in the docs on how to listen for the update/delete events and for fetching extra information needed to take action when such events get fired

kindred knoll
lusty trout
#

You can fetch extra data as needed in the event handler but you cannot add extra data for other listeners to the event (although with a filter you can manipulate the incoming data before it gets saved to the database)

kindred knoll
#

for example, can I change the "keys" to values of another field than the primary db key?

lusty trout
#

With the primary key you can fetch any field you desire 🙂

vocal willow
#

@lusty trout I’d be very interested to see more examples of hooks. I’m working on a bunch and even if not the same use case I’d find it really helpful just in terms of scaffolding

lusty trout
vocal willow
#

Awesome thanks @lusty trout !!!

kindred knoll
# lusty trout With the primary key you can fetch any field you desire 🙂

unless the event is that the item was just deleted*

(*then of course I can retrieve it from the last but one revision, but since i happen to need the very last revision as well, this makes further batch operations all but impossible. if I had the relevant data in the event then I wouldn't need to query the DB for something that's no longer there)

lusty trout
kindred knoll