This repository has been archived by the owner on Jul 5, 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.
(Needs this one to be merged too: ensemble/EnsembleKernelDoctrineOrm#3)
Hi Jurians,
I'm not using Ensemble yet, but I just reading the code as I may need it for my next project.
This PR brings more flexibility based on what I've did on ZfrForum when you need to support multiple adapters, which is the case here - DoctrineORM and Zend\Db, maybe MongoDB in the future... - (see my blog post here : http://www.michaelgallego.fr/blog/2012/10/23/flexible-multi-db-adapter-architecture-for-generic-modules-in-zf-2/).
Basically, this PR allows to move all the logic of services to Ensemble\Kernel, so that you won't need to duplicate all the code in Ensemble\KernelDoctrineOrm, Ensemble\KernelZendDb, Ensemble\KernelDoctrineMongo... which would have been the case with the current architecture.
Instead, a mapper which is defined in Kernel is injected directly to the service, and methods in service call the mapper. So when using KernelDoctrineOrm, the key "Ensemble\Kernel\Mapper\Page" will return an EntityRepository while in will return a table gateway in ZendDb.
I also removed the interface Ensemble\Service\PageInterface as it does not make sense now. If people want to extend / replace some code of the service, they just extend 'Ensemble\Service\Page', and specify the new class under the key page_service_class.
There is one thing more : my PR adds a dependency to Doctrine\Common in Ensemble\Kernel because the MapperInterface implements ObjectRepository. Of course we can remove this dependency but I find it worth it, for two reasons :