Skip to content

Commit

Permalink
Always pass context as argument, even if null
Browse files Browse the repository at this point in the history
  • Loading branch information
codeliner committed Aug 29, 2019
1 parent 07b994f commit dc79f85
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Commanding/CommandProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ public function __invoke(Message $command): array

$aggregate = null;
$aggregateState = null;
$context = null;
$expectedVersion = $command->metadata()[GenericCommand::META_EXPECTED_AGGREGATE_VERSION] ?? null;

if ($this->createAggregate) {
Expand All @@ -250,18 +249,17 @@ public function __invoke(Message $command): array
$aggregateState = $aggregate->currentState();
}

$services = $this->services;

if ($this->contextProvider) {
$context = $this->flavour->callContextProvider($this->contextProvider, $command);
$this->log->contextProviderCalled($this->contextProvider, $command, $context);
}

$arFunc = $this->aggregateFunction;
$services = $this->services;

if($context !== null) {
\array_unshift($services, $context);
}

$arFunc = $this->aggregateFunction;

if ($this->createAggregate) {
$events = $this->flavour->callAggregateFactory($this->aggregateType, $arFunc, $command, ...$services);
} else {
Expand Down

0 comments on commit dc79f85

Please sign in to comment.