On Wed, Feb 20, 2013 at 8:49 AM, <[email protected]> wrote: > > > On Wednesday, February 20, 2013 2:05:49 AM UTC+2, cricket wrote: >> >> >> Better to implement this in a component ... as long as your events >> will always be triggered from within a controller. That is, you won't >> be calling it in an afterDelete() callback. From the controller: >> >> $this->Notifier->send('ModelName', ...); >> >> Or, maybe pass it a keyed array. In any case, better as a component, imho. > > The manual says "To access/use a model in a component is not generally > recommended" and this will need to access several models (at least the > EmailNotification model to determine who to send to as well as other models > to map the specific instance of the updated model to a particular client).
I'm suggesting that you don't use a model at all, just the model names (the ones being monitored) as a key for Configure. That is, place all that in your bootstrap. Unless, you need to fetch this info from the DB. > What is the advantage of a component over the other alternatives I raised? The controller is the right place to be monitoring events. By registering the NotifierComponent in those controllers that need to implement it you're adding an extra functionality, in a similar manner as with models and behaviors. -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cake-php?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
