PHP code example of fintem / mq-notification-bundle

1. Go to this page and download the library: Download fintem/mq-notification-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/ */

    

fintem / mq-notification-bundle example snippets



// ...
        $bundles = [
            // ...
            new OldSound\RabbitMqBundle\OldSoundRabbitMqBundle(),
            new Fintem\MQNotificationBundle\MQNotificationBundle(),
        ];

// ...
}



use Fintem\MQNotificationBundle\Event\NotifyEvent;

$notifyOnTerminate = false; // push notification on kernel/console terminate/exception
$event = new NotifyEvent('test_message', ['some' => 'data'], $notifyOnTerminate);
$this->dispatcher->dispatch(NotifyEvent::NAME, $event);



use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Fintem\MQNotificationBundle\Event\NotificationReceivedEvent;

class NotificationSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return [
            'notification_received' => ['onNotificationReceived', 0],
            'notification_received.user_created' => ['onUserCreated', 0],
        ];
    }
    
    public function onNotificationReceived(NotificationReceivedEvent $event)
    {
    }
    
    public function onUserCreated(NotificationReceivedEvent $event)
    {
        // $user = $event->getData();
    }
}