Which Design Pattern can help me when I need send different emails in different actions |
[eluser]Unknown[/eluser]
Sorry for my poor English. In my project, there are many actions (I call the function in Controller action) need to send an email to user after manipulating database. For example, when a user (account) has been created, an email need to be sent to him to welcome him; when a purchase order has been placed by a user, another email need to be sent, and so on. Code: <?php I don't think it is a good method to hardcode those $this->email after manipulating database via Model's API, because * It is not a mission to the action whose mission is to manipulate database to send an email. * The piece of code about sending an email varies frequently. For example, One day, my boss said, let's send a new type of email when a user changes his order, or we need a more beautiful email template when a user registered successfully. * If an action does not need to send an email any more, I need to delete or comment the piece of code. Which action need to send an email, and which not, this is not configurable via a config file. Is there a design pattern can help me to resolve this problem? I read a few documents about Observer Patter, is it suitable for my problem? Thank you. |
Messages In This Thread |
Which Design Pattern can help me when I need send different emails in different actions - by El Forum - 11-28-2010, 09:04 AM
Which Design Pattern can help me when I need send different emails in different actions - by El Forum - 11-28-2010, 01:17 PM
|