AggregateType in RepositoryFactory
prolic opened this issue ยท 4 comments
Currently:
$aggregateType = AggregateType::fromAggregateRootClass($config['aggregate_type']);
see https://github.com/prooph/event-sourcing/blob/master/src/Container/Aggregate/AggregateRepositoryFactory.php#L85
Maybe it should be AggregateType::fromString($config['aggregate_type']);
or maybe like this:
if (class_exists($config['aggregate_type'])){
$aggregateType = AggregateType::fromAggregateRootClass($config['aggregate_type']);
} else {
$aggregateType = AggregateType::fromString($config['aggregate_type']);
}
Maybe this can be considered a BC? I don't know.
Thoughts?
Also note this:
https://github.com/prooph/event-sourcing/blob/master/src/EventStoreIntegration/AggregateRootDecorator.php#L51-L60
Maybe there is a way to get a mapping implemented as well?
@prolic with the class_exists check it should not be a BC break I guess
Mapping is good idea. Every now and then it pops up in the chat. Everybody is looking for a way to avoid class names in the database be it message classes or aggregate types. We should think about a mapping mechanism provided by prooph that uses FQCNs only as a fallback and maybe remove FQCNs with the next majors entirely.
๐ Will work on it this weekend.