Skip to content

0.8.0 Dev Release

Pre-release
Pre-release

Choose a tag to compare

@codeliner codeliner released this 30 Aug 17:14
· 42 commits to master since this release
991f608

Added

  • #16 Allow multiple contexts to be injected in an aggregate function

Fixed

  • #14 - Force replay when rebuilding aggregate state
  • #15 - Always pass context as argument even in case it is null

BC Break

The Bugfix #15 and the new Feature #16 can cause a BC Break if you use a ContextProvider that returns null or has a void return type. Prior to this release a null context was ignored by Event Engine. If you inject one or more services in the same aggregate function, the services would directly be injected after the command. This is fixed now. Hence, the aggregate function receives a null after the command followed by services.
We consider this change a bugfix, because null is a valid context and should not be ignored by Event Engine.

Let's use an example to make it clear:

Release < 0.8

$eventEngine->process(Command::DO_SOMETHING)
  ->withNew(Aggregate::SOMETHING)
  ->provideContext(NullContextProvider::class)
  ->provideService(SomeService::class)
  // Using a closure as aggregate function for easier understanding
  // SomeService is directly injected after the command
  ->handle(function (Message $doSomething, SomeService $someService) {
  })

Release >= 0.8

$eventEngine->process(Command::DO_SOMETHING)
  ->withNew(Aggregate::SOMETHING)
  ->provideContext(NullContextProvider::class)
  ->provideService(SomeService::class)
  // Null is injected (result of the context provider call) followed by the service
  ->handle(function (Message $doSomething, $nullableContext, SomeService $someService) {
  })