This extention provide an easy way to send dataobjects to an external sites via json, whenever a pimcore event occurs on a specified class. This bundle installs the webHook class through which it is possible to define, from the UI, which dataObjects to listen for sending data to an external website, whenever a pimcore event occurs on the specified dataobject.
For installig WebHookBundle, the first step is to open your terminal and type:
docker-compose exec php bash
composer require sintra/pimcore-webhooks:dev-main
After you have installed the Toolbox Bundle via composer, open pimcore backend and go to Tools
=> Extension
:
- Click the green
+
Button inEnable / Disable
row - Click the green
+
Button inInstall/Uninstall
row
Now that the bundle is installed you can start creating your webhooks!. Follows the next stesp.
- create a folder called
Webhooks
. Although this is not mandatory and you can name it as you want. - create a webhook object in it:
- In setting panel you can specify the name of the classes to monitor, the events to listen to, and the URL of the site to send the json object
- In the security panel, you can set an api-key to provie to the specified URS, an a pair of public/private key to generate a signature
The following video shows how this can be done in seconds. Now you are ready to use the Webhok bundle!
You can specify:
- The class to monitor
- The URL to send data to
- The event to listen
The aviable event are:
- preAdd
- postAdd
- postAddFailure
- preUpdate
- postUpdate
- postUpdateFailure
- deleteInfo
- preDelete
- postDelete
- postDeleteFailure
- postCopy
- postCsvItemExport
Once the event occurs, the json represtantion of you data is sent to the specified url. In the header it is specified which event was launched.
Each event will trigger a request like this:
- headers
x-listen-event
: contain the name of the event launchedx-apikey
: contain a random generated key for autentication porpousex-signature
: contain the data signature created with OPENSSL_ALGO_SHA1; public key is store in website settings
- body contains two main parts:
dataObject
: json representation of your dataObjectargumentrs
: exception code and message throws if a failure occurs
To ensure the authenticity and security of the information transmitted, in the header there are a randomly generated api-key, and a signature generated through a pair of keys (public / private), stored in the Pimcore website setting. These are created automatically when the bundle is installed, but you can use your own.
To run the tests you don't need to create any webhooks or classes, these will be created automatically, you just have to initialize the testURL attribute with a valid url.