Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow encapsulation of AggregateRepository #84

Closed
BreiteSeite opened this issue Aug 24, 2018 · 1 comment
Closed

Allow encapsulation of AggregateRepository #84

BreiteSeite opened this issue Aug 24, 2018 · 1 comment

Comments

@BreiteSeite
Copy link

The only way currently to use the AggregateRepositoryFactory is to create a class that inherits from AggregateRepository.

This has multiple drawbacks. Two of them are:

  • My repositories suddenly exposes more public functions than i like (for example getAggregateRoot).
  • it it makes testing more difficult

Technical it's possible to create an instance of AggregateRepository (no subclass of it) and put it as dependency into my repository and use it (as AggregateRepository::saveAggregateRoot() and AggregateRepository::getAggregateRoot() are public functions).

The only things thats prevent me from doing it is this check in AggregateRepositoryFactory:

if (! \is_subclass_of($repositoryClass, AggregateRepository::class)) {
    throw ConfigurationException::configurationError(\sprintf(
        'Repository class %s must be a sub class of %s',
        $repositoryClass,
        AggregateRepository::class
    ));
 }

I think the check here should use is_a(), to allow me to create not only children of AggregateRepositories, but also direct instances of AggregateRepository.

If you can confirm that it is a valid approach to create the factory without creating subclasses of it, i could create a pull request for it.

@prolic
Copy link
Member

prolic commented Aug 24, 2018

This library is meant as a blueprint for you to create your own implementation. Your domain model shouldn't have dependencies to a framework or library.

@prolic prolic closed this as completed Aug 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants