Skip to content
This repository has been archived by the owner on Jul 28, 2022. It is now read-only.

Commit

Permalink
Merge 22c1fb4 into b9de523
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Feb 12, 2020
2 parents b9de523 + 22c1fb4 commit 7d83a83
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -30,6 +30,7 @@
"symfony/console": "^4.4",
"symfony/dependency-injection": "^4.4",
"symfony/event-dispatcher": "^4.4",
"symfony/event-dispatcher-contracts": "^1.1",
"symfony/form": "^4.4",
"symfony/http-foundation": "^4.4",
"symfony/http-kernel": "^4.4",
Expand Down
2 changes: 1 addition & 1 deletion src/Backend/AMQPBackend.php
Expand Up @@ -226,7 +226,7 @@ public function handle(MessageInterface $message, EventDispatcherInterface $disp
$amqpMessage = $message->getValue('interopMessage');

try {
$dispatcher->dispatch($message->getType(), $event);
$dispatcher->dispatch($event, $message->getType());

$this->consumer->acknowledge($amqpMessage);

Expand Down
2 changes: 1 addition & 1 deletion src/Backend/MessageManagerBackend.php
Expand Up @@ -146,7 +146,7 @@ public function handle(MessageInterface $message, EventDispatcherInterface $disp
$message->setState(MessageInterface::STATE_IN_PROGRESS);
$this->messageManager->save($message);

$dispatcher->dispatch($message->getType(), $event);
$dispatcher->dispatch($event, $message->getType());

$message->setCompletedAt(new \DateTime());
$message->setState(MessageInterface::STATE_DONE);
Expand Down
2 changes: 1 addition & 1 deletion src/Backend/RuntimeBackend.php
Expand Up @@ -93,7 +93,7 @@ public function handle(MessageInterface $message, EventDispatcherInterface $disp
$event = new ConsumerEvent($message);

try {
$dispatcher->dispatch($message->getType(), $event);
$dispatcher->dispatch($event, $message->getType());

$message->setCompletedAt(new \DateTime());
$message->setState(MessageInterface::STATE_DONE);
Expand Down
5 changes: 3 additions & 2 deletions src/Command/ConsumerHandlerCommand.php
Expand Up @@ -23,6 +23,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

class ConsumerHandlerCommand extends ContainerAwareCommand
{
Expand Down Expand Up @@ -135,8 +136,8 @@ public function execute(InputInterface $input, OutputInterface $output)
}

$this->getEventDispatcher()->dispatch(
IterateEvent::EVENT_NAME,
new IterateEvent($iterator, $backend, $message)
new IterateEvent($iterator, $backend, $message),
IterateEvent::EVENT_NAME
);

if ($input->getOption('iteration') && $i >= (int) $input->getOption('iteration')) {
Expand Down
4 changes: 3 additions & 1 deletion src/Command/RestartCommand.php
Expand Up @@ -22,6 +22,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

class RestartCommand extends ContainerAwareCommand
{
Expand Down Expand Up @@ -80,6 +81,7 @@ public function execute(InputInterface $input, OutputInterface $output)
}
}

/** @var EventDispatcherInterface $eventDispatcher */
$eventDispatcher = $this->getContainer()->get('event_dispatcher');

foreach ($messages as $message) {
Expand All @@ -98,7 +100,7 @@ public function execute(InputInterface $input, OutputInterface $output)
));

if ($pullMode) {
$eventDispatcher->dispatch(IterateEvent::EVENT_NAME, new IterateEvent($messages, null, $newMessage));
$eventDispatcher->dispatch(new IterateEvent($messages, null, $newMessage), IterateEvent::EVENT_NAME);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Consumer/ConsumerEvent.php
Expand Up @@ -14,7 +14,7 @@
namespace Sonata\NotificationBundle\Consumer;

use Sonata\NotificationBundle\Model\MessageInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;

class ConsumerEvent extends Event implements ConsumerEventInterface
{
Expand Down
2 changes: 1 addition & 1 deletion src/Event/IterateEvent.php
Expand Up @@ -16,7 +16,7 @@
use Sonata\NotificationBundle\Backend\BackendInterface;
use Sonata\NotificationBundle\Iterator\MessageIteratorInterface;
use Sonata\NotificationBundle\Model\MessageInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Contracts\EventDispatcher\Event;

/**
* Event for ConsumerHandlerCommand iterations event.
Expand Down
5 changes: 3 additions & 2 deletions tests/Backend/PostponeRuntimeBackendTest.php
Expand Up @@ -19,6 +19,7 @@
use Sonata\NotificationBundle\Model\MessageInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
use ZendDiagnostics\Result\Success;

/**
Expand Down Expand Up @@ -90,7 +91,7 @@ public function testLiveEnvironment()
$phpunit->passed = true;
});

$dispatcher->dispatch('kernel.terminate');
$dispatcher->dispatch(new GenericEvent(), 'kernel.terminate');

$this->assertTrue($phpunit->passed);
$this->assertSame(MessageInterface::STATE_DONE, $message->getState());
Expand Down Expand Up @@ -125,7 +126,7 @@ public function testRecursiveMessage()
$phpunit->passed2 = true;
});

$dispatcher->dispatch('kernel.terminate');
$dispatcher->dispatch(new GenericEvent(), 'kernel.terminate');

$this->assertTrue($phpunit->passed1);
$this->assertTrue($phpunit->passed2);
Expand Down

0 comments on commit 7d83a83

Please sign in to comment.