The following examples show you how to use Event_Dispatcher to create more flexible applications.
Example 36-1. 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. |
Example 36-2. 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. |