/** * {@inheritDoc} */ public function execute($command) { $this->queue->enqueue($command); if (!$this->isDispatching) { $this->isDispatching = true; try { while (!$this->queue->isEmpty()) { $this->processCommand($this->queue->pop()); } } finally { $this->isDispatching = false; } } }
/** * {@inheritDoc} */ public function publish(DomainEventInterface $event) { $this->queue->enqueue($event); if (!$this->isPublishing && !$this->queue->isEmpty()) { $this->isPublishing = true; try { while (!$this->queue->isEmpty()) { $this->processEvent($this->queue->pop()); } } finally { $this->isPublishing = false; } } }