How can I access a service outside of a controller with Symfony2?

后端 未结 2 823
天命终不由人
天命终不由人 2020-11-28 19:14

I\'m building a site that relies quite heavily on a third party API so I thought it would make sense to package up the API wrapper as a service, however I\'m starting to fin

2条回答
  •  一整个雨季
    2020-11-28 19:51

    I would wrap this kind of behavior in a Symfony service(like a manager). i would not inject any parameters or logic into the entity repositories, as they should mainly be used to fetch data using object manager queries. I would put the logic in the services and if the service , require a database access it will call the entity repository to fetch data.

提交回复
热议问题