| @@ 97-114 (lines=18) @@ | ||
| 94 | * @param CommandHandlerAndAggregate $handlerAndAggregate |
|
| 95 | * @return void |
|
| 96 | */ |
|
| 97 | private function applyCommand(CommandWithMetadata $command, CommandHandlerAndAggregate $handlerAndAggregate) |
|
| 98 | { |
|
| 99 | $aggregate = $handlerAndAggregate->getAggregate(); |
|
| 100 | $handler = $handlerAndAggregate->getCommandHandler(); |
|
| 101 | ||
| 102 | $metaData = $this->eventMetadataFactory->factoryEventMetadata($command, $aggregate); |
|
| 103 | ||
| 104 | $newMessageGenerator = $this->commandApplier->applyCommand($aggregate, $command->getCommand(), $handler->getMethodName()); |
|
| 105 | ||
| 106 | foreach ($newMessageGenerator as $message) { |
|
| 107 | if (!$this->isScheduledCommand($message)) { |
|
| 108 | $eventWithMetaData = $this->decorateEventWithMetaData($message, $metaData); |
|
| 109 | if (!$this->isScheduledEvent($message)) { |
|
| 110 | $this->eventsApplierOnAggregate->applyEventsOnAggregate($aggregate, [$eventWithMetaData]); |
|
| 111 | } |
|
| 112 | } |
|
| 113 | } |
|
| 114 | } |
|
| 115 | ||
| 116 | private function isScheduledEvent($event): bool |
|
| 117 | { |
|
| @@ 96-113 (lines=18) @@ | ||
| 93 | * @param CommandHandlerAndAggregate $handlerAndAggregate |
|
| 94 | * @return void |
|
| 95 | */ |
|
| 96 | private function applyCommand(CommandWithMetadata $command, CommandHandlerAndAggregate $handlerAndAggregate) |
|
| 97 | { |
|
| 98 | $aggregate = $handlerAndAggregate->getAggregate(); |
|
| 99 | $handler = $handlerAndAggregate->getCommandHandler(); |
|
| 100 | ||
| 101 | $metaData = $this->eventMetadataFactory->factoryEventMetadata($command, $aggregate); |
|
| 102 | ||
| 103 | $newMessageGenerator = $this->commandApplier->applyCommand($aggregate, $command->getCommand(), $handler->getMethodName()); |
|
| 104 | ||
| 105 | foreach ($newMessageGenerator as $message) { |
|
| 106 | if (!$this->isScheduledCommand($message)) { |
|
| 107 | $eventWithMetaData = $this->decorateEventWithMetaData($message, $metaData); |
|
| 108 | if (!$this->isScheduledEvent($message)) { |
|
| 109 | $this->eventsApplierOnAggregate->applyEventsOnAggregate($aggregate, [$eventWithMetaData]); |
|
| 110 | } |
|
| 111 | } |
|
| 112 | } |
|
| 113 | } |
|
| 114 | ||
| 115 | private function isScheduledEvent($event): bool |
|
| 116 | { |
|