Skip to content

Commit

Permalink
Fix event dispatcher deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny van Wijk committed Jan 3, 2020
1 parent 68eefef commit de5bcfb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions src/Bundle/Controller/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use Sylius\Bundle\ResourceBundle\Event\ResourceControllerEvent;
use Sylius\Component\Resource\Model\ResourceInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface as SymfonyEventDispatcherInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface as SymfonyEventDispatcherInterface;

final class EventDispatcher implements EventDispatcherInterface
{
Expand All @@ -39,7 +39,7 @@ public function dispatch(
$metadata = $requestConfiguration->getMetadata();
$event = new ResourceControllerEvent($resource);

$this->eventDispatcher->dispatch(sprintf('%s.%s.%s', $metadata->getApplicationName(), $metadata->getName(), $eventName), $event);
$this->eventDispatcher->dispatch($event, sprintf('%s.%s.%s', $metadata->getApplicationName(), $metadata->getName(), $eventName));

return $event;
}
Expand All @@ -56,7 +56,7 @@ public function dispatchMultiple(
$metadata = $requestConfiguration->getMetadata();
$event = new ResourceControllerEvent($resources);

$this->eventDispatcher->dispatch(sprintf('%s.%s.%s', $metadata->getApplicationName(), $metadata->getName(), $eventName), $event);
$this->eventDispatcher->dispatch($event, sprintf('%s.%s.%s', $metadata->getApplicationName(), $metadata->getName(), $eventName));

return $event;
}
Expand All @@ -73,7 +73,7 @@ public function dispatchPreEvent(
$metadata = $requestConfiguration->getMetadata();
$event = new ResourceControllerEvent($resource);

$this->eventDispatcher->dispatch(sprintf('%s.%s.pre_%s', $metadata->getApplicationName(), $metadata->getName(), $eventName), $event);
$this->eventDispatcher->dispatch($event, sprintf('%s.%s.pre_%s', $metadata->getApplicationName(), $metadata->getName(), $eventName));

return $event;
}
Expand All @@ -90,7 +90,7 @@ public function dispatchPostEvent(
$metadata = $requestConfiguration->getMetadata();
$event = new ResourceControllerEvent($resource);

$this->eventDispatcher->dispatch(sprintf('%s.%s.post_%s', $metadata->getApplicationName(), $metadata->getName(), $eventName), $event);
$this->eventDispatcher->dispatch($event, sprintf('%s.%s.post_%s', $metadata->getApplicationName(), $metadata->getName(), $eventName));

return $event;
}
Expand All @@ -108,8 +108,8 @@ public function dispatchInitializeEvent(
$event = new ResourceControllerEvent($resource);

$this->eventDispatcher->dispatch(
sprintf('%s.%s.initialize_%s', $metadata->getApplicationName(), $metadata->getName(), $eventName),
$event
$event,
sprintf('%s.%s.initialize_%s', $metadata->getApplicationName(), $metadata->getName(), $eventName)
);

return $event;
Expand Down
16 changes: 8 additions & 8 deletions src/Bundle/spec/Controller/EventDispatcherSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Sylius\Component\Resource\Metadata\MetadataInterface;
use Sylius\Component\Resource\Model\ResourceInterface;
use Sylius\Component\Resource\ResourceActions;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

final class EventDispatcherSpec extends ObjectBehavior
{
Expand All @@ -47,7 +47,7 @@ function it_dispatches_appropriate_event_for_a_resource(
$metadata->getApplicationName()->willReturn('sylius');
$metadata->getName()->willReturn('product');

$eventDispatcher->dispatch('sylius.product.show', Argument::type(ResourceControllerEvent::class))->shouldBeCalled();
$eventDispatcher->dispatch(Argument::type(ResourceControllerEvent::class), 'sylius.product.show')->shouldBeCalled();

$this->dispatch(ResourceActions::SHOW, $requestConfiguration, $resource)->shouldHaveType(ResourceControllerEvent::class);
}
Expand All @@ -63,7 +63,7 @@ function it_dispatches_appropriate_custom_event_for_a_resource(
$metadata->getApplicationName()->willReturn('sylius');
$metadata->getName()->willReturn('product');

$eventDispatcher->dispatch('sylius.product.register', Argument::type(ResourceControllerEvent::class))->shouldBeCalled();
$eventDispatcher->dispatch(Argument::type(ResourceControllerEvent::class), 'sylius.product.register')->shouldBeCalled();

$this->dispatch(ResourceActions::CREATE, $requestConfiguration, $resource)->shouldHaveType(ResourceControllerEvent::class);
}
Expand All @@ -79,7 +79,7 @@ function it_dispatches_event_for_a_collection_of_resources(
$metadata->getApplicationName()->willReturn('sylius');
$metadata->getName()->willReturn('product');

$eventDispatcher->dispatch('sylius.product.register', Argument::type(ResourceControllerEvent::class))->shouldBeCalled();
$eventDispatcher->dispatch(Argument::type(ResourceControllerEvent::class), 'sylius.product.register')->shouldBeCalled();

$this->dispatchMultiple(ResourceActions::CREATE, $requestConfiguration, $resources)->shouldHaveType(ResourceControllerEvent::class);
}
Expand All @@ -95,7 +95,7 @@ function it_dispatches_appropriate_pre_event_for_a_resource(
$metadata->getApplicationName()->willReturn('sylius');
$metadata->getName()->willReturn('product');

$eventDispatcher->dispatch('sylius.product.pre_create', Argument::type(ResourceControllerEvent::class))->shouldBeCalled();
$eventDispatcher->dispatch(Argument::type(ResourceControllerEvent::class), 'sylius.product.pre_create')->shouldBeCalled();

$this->dispatchPreEvent(ResourceActions::CREATE, $requestConfiguration, $resource);
}
Expand All @@ -111,7 +111,7 @@ function it_dispatches_appropriate_custom_pre_event_for_a_resource(
$metadata->getApplicationName()->willReturn('sylius');
$metadata->getName()->willReturn('product');

$eventDispatcher->dispatch('sylius.product.pre_register', Argument::type(ResourceControllerEvent::class))->shouldBeCalled();
$eventDispatcher->dispatch(Argument::type(ResourceControllerEvent::class), 'sylius.product.pre_register')->shouldBeCalled();

$this->dispatchPreEvent(ResourceActions::CREATE, $requestConfiguration, $resource);
}
Expand All @@ -127,7 +127,7 @@ function it_dispatches_appropriate_post_event_for_a_resource(
$metadata->getApplicationName()->willReturn('sylius');
$metadata->getName()->willReturn('product');

$eventDispatcher->dispatch('sylius.product.post_create', Argument::type(ResourceControllerEvent::class))->shouldBeCalled();
$eventDispatcher->dispatch(Argument::type(ResourceControllerEvent::class), 'sylius.product.post_create')->shouldBeCalled();

$this->dispatchPostEvent(ResourceActions::CREATE, $requestConfiguration, $resource);
}
Expand All @@ -143,7 +143,7 @@ function it_dispatches_appropriate_custom_post_event_for_a_resource(
$metadata->getApplicationName()->willReturn('sylius');
$metadata->getName()->willReturn('product');

$eventDispatcher->dispatch('sylius.product.post_register', Argument::type(ResourceControllerEvent::class))->shouldBeCalled();
$eventDispatcher->dispatch(Argument::type(ResourceControllerEvent::class), 'sylius.product.post_register')->shouldBeCalled();

$this->dispatchPostEvent(ResourceActions::CREATE, $requestConfiguration, $resource)->shouldHaveType(ResourceControllerEvent::class);
}
Expand Down

0 comments on commit de5bcfb

Please sign in to comment.