This plugin can be used to lazy load message handlers. Initialize it with a Interop\Container\ContainerInterface and route your messages to the service id only.
Автор: Alexander Miertsch (kontakt@codeliner.ws)
Наследование: implements Prooph\Common\Event\ActionEventListenerAggregate, use trait Prooph\Common\Event\DetachAggregateHandlers
 /**
  * @test
  */
 public function it_locates_a_service_using_the_message_handler_param_of_the_action_event()
 {
     $handler = new MessageHandler();
     $container = $this->prophesize(ContainerInterface::class);
     $container->has("custom-handler")->willReturn(true);
     $container->get("custom-handler")->willReturn($handler);
     $locatorPlugin = new ServiceLocatorPlugin($container->reveal());
     $actionEvent = new DefaultActionEvent(MessageBus::EVENT_LOCATE_HANDLER, new CommandBus(), [MessageBus::EVENT_PARAM_MESSAGE_HANDLER => "custom-handler"]);
     $locatorPlugin->onLocateMessageHandler($actionEvent);
     $this->assertSame($handler, $actionEvent->getParam(MessageBus::EVENT_PARAM_MESSAGE_HANDLER));
 }