Injecting repositories to service in Symfony2

It is generally a good idea to wrap business logic into services. Often, such services methods use doctrine’s repositories to operate on data storage. Injecting whole EntityManager service is a very popular approach, but it isn’t the most elegant way I could think of. EntityManager works only as a factory in that case and could lead to usage of other repositories, which might end up with too many responsibilities of given service.
The better way is to inject single repositories, using a factory-service mechanism, provided by the Dependency Injection Container.f

Read more