Symfony4-REST-API icon indicating copy to clipboard operation
Symfony4-REST-API copied to clipboard

Repository depends on Model

Open chimit opened this issue 6 years ago • 1 comments

Hi! I'm just curious. Your low-level repository class depends on a high-level Article model. Isn't it a violation of the Dependency Inversion principle and we should define an Article interface?

chimit avatar Oct 20 '19 09:10 chimit

Hi Chimit

Actually Infrastructure level is higher than Domain. Infrastructure layer must implement all the interfaces defined in lower levels using framework and other dependences. You can see there, that ArticleRepository implements ArticleRepositoryInterface.

Application layer is higher than Domain and lower than Infrastructure. It can orchestrate Domain models and work with any interfaces defined on Domain/Application layers. Like ArticleRepositoryInterface, PasswordEncoderInterface or DispatcherInterface.

blry avatar Jan 16 '20 21:01 blry