This repository has been archived by the owner on Feb 21, 2022. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why AggregateResource so strongly coupled with domain model ?
https://github.com/beberlei/litecqrs-php/blob/master/src/LiteCQRS/Plugin/CRUD/AggregateResource.php#L23
I think, inherit domain model from AggregateResource is not a good idea. Better to design without LiteCQRS dependency and incapsulate all in CRUDHelper. In this way we can keep old behaviour with setter/getter anemic domain, we can safely remove LiteCQRS library and refactor only small pieces of code (controller helper).
See LiteCQRS\Plugin\CRUD\CRUDCommandService. In my version, domain model is clear, but DomainAggregateResource decorates it.
About domain model accessible properties detection and update. There is a few ways to detect accessible properties in our domain. Map method in domain (getAccessibleProperties), setter method_exists, reflection property detection, annotations, config.
I realize first 3 methods in LiteCQRS\Plugin\CRUD\Updater\Filter components. UniversalFilter chains all of them and filters $event->data.
Filtered data from event can be writed through domain setters (LiteCQRS\Plugin\CRUD\Updater\SetterBasedUpdater), or injected directly to domain properties through reflection (LiteCQRS\Plugin\CRUD\Updater\ReflectionBasedUpdater). In reflection based updater we can unprotect domain property store value from event data and protect it back.
I incapsulate some components to traits, DomainAggregateResource - uses DomainAsProperty trait, and AggregateResource - uses DomainAsAggregate.
Some limitations (or not): our repository now is not AggregateRepositoryInterface, it stores any domain object.