Skip to content
Snippets Groups Projects
Commit 8ed715e7 authored by Sean Madsen's avatar Sean Madsen
Browse files

Refer to example of good way to add pre/post hooks to core

parent e28047ef
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,9 @@ deleted first). ...@@ -14,7 +14,9 @@ deleted first).
!!! note !!! note
These hooks use database transactions. Don't execute code that updates the same data in the database without using a callback. Eg. if triggering on a `Membership` entity, don't try and update that membership entity within the hook. Use CRM_Core_Transaction::addCallback() instead. These hooks use database transactions. Don't execute code that updates the same data in the database without using a callback. Eg. if triggering on a `Membership` entity, don't try and update that membership entity within the hook. Use CRM_Core_Transaction::addCallback() instead.
!!! tip
Some of the more esoteric entities may not fire this hook when they're saved. If you happen to find such an entity, please make a PR to core which adds this hook. As an example, you can refer to `CRM_Core_BAO_Dashboard::create()` to find succinct syntax that appropriately calls both `CRM_Utils_Hook::pre()` and `CRM_Utils_Hook::post()`.
## Definition ## Definition
......
...@@ -15,6 +15,9 @@ constraints etc (when deleting an object, the child objects have to be ...@@ -15,6 +15,9 @@ constraints etc (when deleting an object, the child objects have to be
deleted first). Another good use for the pre hook is to see what is deleted first). Another good use for the pre hook is to see what is
changing between the old and new data. changing between the old and new data.
!!! tip
Some of the more esoteric entities may not fire this hook when they're saved. If you happen to find such an entity, please make a PR to core which adds this hook. As an example, you can refer to `CRM_Core_BAO_Dashboard::create()` to find succinct syntax that appropriately calls both `CRM_Utils_Hook::pre()` and `CRM_Utils_Hook::post()`.
## Definition ## Definition
hook_civicrm_pre($op, $objectName, $id, &$params) hook_civicrm_pre($op, $objectName, $id, &$params)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment