Introduction | Event_Dispatcher::getInstance |
Event_Dispatcher | |
PEAR Manual | |
The following examples show you how to use Event_Dispatcher to create more flexible applications.
Basic example
|
In this example, Event_Dispatcher is used to allow observers to hook into the authentication process. Whenever a user authenticates, a notification onLogin is sent.
This can be used to write logfiles or block the application for other users.
Cancelling notifications
|
In this case, the cancelNotification() method is used to cancel the notification if a certain user tries to authenticate.
The login method has been changed as well to check whether the notification has been cancelled and to take the necessary steps.
This allows you to add some flexible rules to your authentication system.
Introduction | Event_Dispatcher::getInstance |
Event_Dispatcher | |
PEAR Manual | |