Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Decouple AggregateResource #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Decouple AggregateResource #22

wants to merge 1 commit into from

Conversation

zerkalica
Copy link

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.

@beberlei
Copy link
Owner

Thanks for your pull request, I have to review first before I can say something about it :)

@stof
Copy link

stof commented Nov 21, 2012

Using traits bumps the requirement to PHP 5.4 whereas the current library is compatible with 5.3

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants