PHP code example of bitbirddev / trustkey-webhook-bundle

1. Go to this page and download the library: Download bitbirddev/trustkey-webhook-bundle 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/ */

    

bitbirddev / trustkey-webhook-bundle example snippets




namespace App\Webhooks\Consumer;

/*
 * In case Messages are delivered Async
 * make sure bin/console messenger:consume async is running
 */

use bitbirddev\TrustkeyWebhookBundle\Events\ActionPackEvent;
use bitbirddev\TrustkeyWebhookBundle\Events\ComponentEvent;
use bitbirddev\TrustkeyWebhookBundle\Events\ResourceEvent;
use bitbirddev\TrustkeyWebhookBundle\Events\SectionEvent;
use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
use Symfony\Component\RemoteEvent\Consumer\ConsumerInterface;
use Symfony\Component\RemoteEvent\Exception\LogicException;
use Symfony\Component\RemoteEvent\RemoteEvent;

#[AsRemoteEventConsumer('trustkey')]
class TrustkeyWebhookConsumer implements ConsumerInterface
{
    public function consume(RemoteEvent $event): void
    {
        match ($event->getName()) {
            // Resources
            ResourceEvent::CREATED => $this->handle($event),
            ResourceEvent::UPDATED => $this->handle($event),
            ResourceEvent::ARCHIVED => $this->handle($event),

            // ActionPacks
            ActionPackEvent::LAUNCHED => $this->handle($event),
            ActionPackEvent::COMPLETE => $this->handle($event),
            ActionPackEvent::REOPEN => $this->handle($event),

            // Components
            ComponentEvent::PROGRESS_DONE => $this->handle($event),
            ComponentEvent::PROGRESS_REOPEN => $this->handle($event),

            // Sections
            SectionEvent::PROGRESS_DONE => $this->handle($event),
            SectionEvent::PROGRESS_REOPEN => $this->handle($event),

            default => throw new LogicException('Unhandled TrustkeyEvent: '.$event->getName())
        };
    }

    protected function handle(RemoteEvent $event): void
    {
        dd($event);
    }
}