Skip to content

Commit

Permalink
Merge pull request #434 from spatie/support-interfaces-in-aggregate-r…
Browse files Browse the repository at this point in the history
…oot-apply-methods

Support interfaces in aggregate root apply methods
  • Loading branch information
sebastiandedeyne authored Aug 24, 2023
2 parents c1f841a + 378b786 commit e513207
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/AggregateRoots/AggregateRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,11 @@ protected function apply(ShouldBeStored $event): void
->public()
->protected()
->reject(fn (Method $method) => in_array($method->getName(), ['handleCommand', 'recordThat', 'apply', 'tap']))
->acceptsTypes([$event::class])
->accepts($event)
->all()
->each(fn (Method $method) => $this->{$method->getName()}($event));
->each(function (Method $method) use ($event) {
return $this->{$method->getName()}($event);
});

$this->appliedEvents[] = $event;

Expand Down

0 comments on commit e513207

Please sign in to comment.