Tuesday, February 19, 2013

Implementing the Event Notifier Pattern in CakePHP

Does anyone have any advice as to how to go about implementing the Event Notifier pattern in CakePHP 1.3?

Basically, I want to have email notifications sent out when various events occur (adding or deleting instances of specific models).  The notifications can be sent to different e-mail addresses depending on the model that the event occurred on and whether the notification is being sent to the system administrator or to a client specific administrator.

To this end I implemented a model called EmailNotification which has the client id (0 for system admin), the model to be monitored and the email address for the notifications to be sent to.

I would have the models being monitored make a common call with the necessary information for the notification email to be sent out.  It would be the responsibility of this code to look up who the notification should be sent to and to send it out.

My current thought is to have a method on the EmailNotificationsController->notify that would be called by the controllers of the models being monitored using requestAction.

Alternatively, I could load the EmailNotificationsController using App::import and call the method directly from the monitored model's controller.

Or is there a better way to implement this?

Thanks.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: