Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
$eventDispatcher = new EventDispatcher();
$eventDispatcher->addListener(
Bernard\BernardEvents::INVOKE,
function(Bernard\Event\EnvelopeEvent $envelopeEvent) {
echo PHP_EOL . 'Processing: ' . $envelopeEvent->getEnvelope()->getClass();
}
);
$eventDispatcher->addListener(
Bernard\BernardEvents::ACKNOWLEDGE,
function(Bernard\Event\EnvelopeEvent $envelopeEvent) {
echo PHP_EOL . 'Processed: ' . $envelopeEvent->getEnvelope()->getClass();
}
);
$eventDispatcher->addListener(
Bernard\BernardEvents::REJECT,
function(Bernard\Event\RejectEnvelopeEvent $envelopeEvent) {
echo PHP_EOL . 'Failed: ' . $envelopeEvent->getEnvelope()->getClass();
// you can also log error messages here
}
);
$consumer = new Consumer($router, $eventDispatcher);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.