PHP code example of igniterlabs / ti-ext-webhook

1. Go to this page and download the library: Download igniterlabs/ti-ext-webhook library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

igniterlabs / ti-ext-webhook example snippets


public function registerWebhookEvents()
{
    return [
        'events' => [
            'customer' => \IgniterLabs\Webhook\WebhookEvents\Customer::class,
        ],
    ];
}

class Customer extends \IgniterLabs\Webhook\WebhookEvents\BaseEvent
{
    /**
     * Returns information about this event, including name and description.
     */
    public function eventDetails()
    {
        return [
            'name' => 'Customers',
            'description' => 'Customer created, updated or deleted.',
            'setup' => '$/igniterlabs/webhook/webhookevents/customer/setup.md',
        ];
    }

    public static function registerEventListeners()
    {
        return [
            'created' => 'eloquent.created: Admin\Models\Customers_model',
            'updated' => 'eloquent.updated: Admin\Models\Customers_model',
            'deleted' => 'eloquent.deleted: Admin\Models\Customers_model',
        ];
    }

    public static function makePayloadFromEvent(array $args, $actionCode = null)
    {
        $params = [];
        $customer = array_get($args, 0);
        if ($customer instanceof Customers_model)
            $params['customer'] = $customer->toArray();

        return $params;
    }
}