JeffreyVerreckt / Symfony4-REST-API

http://www.thinktocode.com/2018/03/26/symfony-4-rest-api-part-1-fosrestbundle/
51 stars 21 forks source link

Repository depends on Model #5

Open chimit opened 5 years ago

chimit commented 5 years ago

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?

blry commented 4 years ago

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.