Add-on Endpoints
An add-on is able to hook on specific add-on endpoints from the main application. These endpoints can then perform their own actions inside the add-on.
Defining hooks#
In order to listen on these hooks the add-on needs to register them inside the addon.json file. The definition is as followed:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
There are 5 different triggers to listen to:
register: First time registration of the add-onbin/idoit idoit:addons:register http://127.0.0.1:9000
update: Update of already registered add-on. The register is also being used for the update procedure.bin/idoit idoit:addons:register http://127.0.0.1:9000
unregister: Removing the add-on from the main applicationbin/idoit idoit:addons:unregister vendor.identifier
enable: Activating the add-onbin/idoit idoit:addons:enable vendor.identifier
disable: Disabling the add-onbin/idoit idoit:addons:disable vendor.identifier
The vendor and identifier are specified in the addon.json file.
How to listen to an Add-on hook#
Let's assume we want to create three endpoints which listens to the register, unregister and update trigger.
First we have to register the hooks in the addon.json file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
After that we need to define the endpoints for install, uninstall and update inside the add-on. To check it, create the file public\index.php if it has not been created yet and add this example code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Now when we register/update or unregister the add-on then the defined routines will be called which contains add-on specific code.