You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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).
if (! \is_subclass_of($repositoryClass, AggregateRepository::class)) {
throwConfigurationException::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.
The text was updated successfully, but these errors were encountered:
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.
The only way currently to use the
AggregateRepositoryFactory
is to create a class that inherits fromAggregateRepository
.This has multiple drawbacks. Two of them are:
getAggregateRoot
).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 (asAggregateRepository::saveAggregateRoot()
andAggregateRepository::getAggregateRoot()
are public functions).The only things thats prevent me from doing it is this check in
AggregateRepositoryFactory
: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.
The text was updated successfully, but these errors were encountered: