With the various changes for the Generic DB introduced in version 4.9 there also came the generic execution of callbacks, which can be registered dynamically. They mostly behave like the Chain system by executing an individual callback.
There are 9 different event types which can be handled with the generic execution.
|Name of event||Description||Expected parameters|
|CREATE_BEFORE||Executed before an item is created.||none|
|CREATE_FAILURE||Executed if item could not be created.||none|
|CREATE_SUCCESS||Executed it item could be created successfully.||ID of created item|
|STORE_BEFORE||Executed before store process is executed.||Item instance|
|STORE_FAILURE||Executed if store process failed. |
This is also likely to happen if query would not change anything in database!
|STORE_SUCCESS||Executed if store process saved the values in the database.||Item instance|
|DELETE_BEFORE||Executed before deleting an item||ID of the item to delete|
|DELETE_FAILURE||Executed if deletion of an item fails||ID of the item to delete|
|DELETE_SUCCESS||Executed if item was deleted successfully.||ID of the item to delete|
Callbacks can be registered by using the static method "register" of the "cGenericDb" class.
The first parameter is the event name, which is stored as class constant. The second parameter is a valid callback, which is executed. The third parameter is the class name of the Item class, for which the callback should be registered.
Callbacks can only be unregistered at all for a single event in a class. Unregistering only one of multiple callbacks of a classes callback event is not supported yet.