git checkout lesson-2
Product.
Aggregate
annotation marks class to be known as AggregateAggregateIdentififer
marks properties as identifiers of specific Aggregate instance. Each Aggregate must contains at least one identifier. CommandHandler
enables command handling on specific method just as we did in Lesson 1.
If method is static, it's treated as factory method and must return new aggregate instance. Rule applies as long as we use State-Stored Aggregate instead of Event Sourcing Aggregate.QueryHandler
enables query handling on specific method just as we did in Lesson 1.App\Domain\Product\ProductService
as it contains handlers for same command and query classes.
Before we will run our test scenario, we need to register Repository
.services
as Query Handlers not aggregates. Ecotone
does not block possibility to place Query Handler on Aggregate. It's up to you, where do you want to place Query Handler.Repository
annotation marks class to be known to Ecotone
as Repository.Ecotone
, retrieve and save Aggregate. Based on implemented interface, Ecotone
knowns, if Aggregate is state-stored or event sourced. canHandle
tells which classes can be handled by this specific repositoryfindBy
return found aggregate instance or null. As there may be more, than single indentifier per aggregate, identifiers are array.save
saves passed aggregate instance. You do not need to bother right what is $metadata
and $expectedVersion
Event Handler
was not called, as we do not publish ProductWasRegistered
event at this moment. AggregateEvents.
This will tell Ecotone
where to get the events from.
Ecotone
comes with default implementation, that can be used as trait WithAggregateEvents
.