dsf12123
2018-04-12 17:23
浏览 53
已采纳

Symfony 3:如何根据某些运行时变量动态注入服务

let's say I have the following interface/concrete classes:

interface EmailFormatter

class CvEmailFormatter implements EmailFormatter
class RegistrationEmailFormatter implements EmailFormatter
class LostPasswordEmailFormatter implements EmailFormatter

I then have a custom 'mailer' service that's called from my controller actions in order to send an email.

What options do I have for injecting the correct implementation of EmailFormatter to my mailer service depending on the type of email being sent?

图片转代码服务由CSDN问答提供 功能建议

假设我有以下接口/具体类:

  interface EmailFormatter 
 
class CvEmailFormatter实现EmailFormatter 
class RegistrationEmailFormatter实现EmailFormatter 
class LostPasswordEmailFormatter实现EmailFormatter 
   
 
 

然后我有一个自定义的“邮件程序”服务 控制器操作以发送电子邮件。

根据发送的电子邮件类型,我有哪些选项可以将正确的EmailFormatter实施注入我的邮件服务? \ n

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题