I’m looking to develop a notification system - to check for unread messages etc - the notification would run a couple of different controllers. Where is the best place to run the checks from?
I was thinking of breaking into the authentication side, and running it there somewhere (would obviously only run if logged in) This feels like a bit of a hack though! I’m wondering if there is somewhere more appropriate.
class CheckNotification extends CBehavior
{
public function attach($owner)
{
$owner->attachEventHandler('onBeginRequest', array($this, 'handleBeginRequest'));
}
public function handleBeginRequest($event)
{
//here comes actual code
}
}
This way you will have a piece of code executed before each and every page request.