protected function setUp() { $this->object = new Setup(); $this->object->setGate(new Gate()); $this->object->setCommandHandlerLoader(new ClassMapCommandHandlerLoader()); $this->object->setEventListenerLoader(new ClassMapEventListenerLoader()); $this->object->setQueryHandlerLoader(new ClassMapQueryHandlerLoader()); }
public function testInitializeWithoutQuerytHandlerLoader() { $this->setExpectedException('Malocher\\Cqrs\\Configuration\\ConfigurationException'); $configuration = array('enable_system_bus' => true, 'adapters' => array('Malocher\\Cqrs\\Adapter\\ArrayMapAdapter' => array('buses' => array('Malocher\\CqrsTest\\Coverage\\Mock\\Bus\\MockBus' => array('Malocher\\CqrsTest\\Coverage\\Mock\\Query\\MockQuery' => array('alias' => 'Malocher\\CqrsTest\\Coverage\\Mock\\Query\\MockQueryHandler', 'method' => 'handleQuery')))))); $this->setup->setGate(new Gate()); $this->setup->setCommandHandlerLoader(new ClassMapCommandHandlerLoader()); $this->setup->setEventListenerLoader(new ClassMapEventListenerLoader()); $this->setup->initialize($configuration); }
/** * */ public function __construct() { $setup = new Setup(); $setup->setGate(new Gate()); $setup->setCommandHandlerLoader(new ClassMapCommandHandlerLoader()); $setup->setEventListenerLoader(new ClassMapEventListenerLoader()); $setup->setQueryHandlerLoader(new ClassMapQueryHandlerLoader()); // iteration 5 $configuration = ['adapters' => ['Malocher\\Cqrs\\Adapter\\AnnotationAdapter' => ['buses' => ['Iteration\\Iteration5\\Iteration5Bus' => ['Iteration\\Iteration5\\Iteration5Handler'], 'Malocher\\Cqrs\\Bus\\SystemBus' => ['Iteration\\Iteration5\\Iteration5Monitor']]]]]; $setup->initialize($configuration); $bus = $setup->getGate()->getBus('iteration-iteration5-bus'); $bus->invokeCommand(new Iteration5Command('Hello')); }
/** * * {@inheritDoc} */ public function createService(ServiceLocatorInterface $serviceLocator) { $configuration = $serviceLocator->get('configuration'); if (!isset($configuration['cqrs'])) { throw new \Exception('CQRS config missing'); } $cqrsConfig = $configuration['cqrs']; $gate = new Gate(); $cqrsSetup = new Setup(); $cqrsSetup->setGate($gate); $cqrsSetup->setCommandHandlerLoader($serviceLocator->get('malocher.cqrs.command_handler_loader')); $cqrsSetup->setQueryHandlerLoader($serviceLocator->get('malocher.cqrs.query_handler_loader')); $cqrsSetup->setEventListenerLoader($serviceLocator->get('malocher.cqrs.event_listener_loader')); $cqrsSetup->initialize($cqrsConfig); return $gate; }