/** * {@inheritdoc} */ public function dispatch(MessageInterface $event) { if (!$event instanceof EventInterface) { throw new \InvalidArgumentException(sprintf('The object must be an instance of %s. Instance of %s given', EventInterface::class, get_class($event))); } $this->ensureEventDispatcherMiddleware(); parent::dispatch($event); }
/** * {@inheritdoc} */ public function dispatch(MessageInterface $command) { if (!$command instanceof CommandInterface) { throw new \InvalidArgumentException(sprintf('The object must be an instance of %s. Instance of %s given', CommandInterface::class, get_class($command))); } $this->ensureCommandHandlerMiddleware(); parent::dispatch($command); }
/** * {@inheritdoc} */ public function dispatch(MessageInterface $query) { if (!$query instanceof QueryInterface) { throw new \InvalidArgumentException(sprintf('The object must be an instance of %s. Instance of %s given', QueryInterface::class, get_class($query))); } $this->ensureQueryHandlerMiddleware(); return parent::dispatch($query); }
/** * Test dispatch method. */ public function testDispatch() { $this->given($middleware = new LockingMiddleware())->and($bus = new Bus([12 => $middleware]))->when($result = $bus->dispatch(new FooMessage()))->then()->variable($result)->isNull(); }