Symfony2: How to access to service from repository

后端 未结 8 1688
有刺的猬
有刺的猬 2020-12-31 13:08

I have class ModelsRepository:

class ModelsRepository extends EntityRepository
{}

And service

container_data:
 class:               


        
8条回答
  •  醉梦人生
    2020-12-31 13:56

    Extending Laurynas Mališauskas answer, to pass service to a constructor make your repository a service too and pass it with arguments:

    models.repository:
          class: ModelsRepository
          arguments: ['@service_you_want_to_pass']
    

提交回复
热议问题