In the preceding section, you saw how you can take advantage of an event-driven model when developing object code. In particular, you saw an example of the class that allows for registering a custom function with an instance of that class, so that this function is invoked whenever a certain event occurs.
Graphically, an event-driven communication might look like that shown in the following diagram:
In the preceding example, you learned that the PEAR::Auth
class allows you to define a custom function that will be invoked automatically whenever a user is successfully authenticated.
However, looking through the Auth.php
source file, you may notice that the Auth
class also allows you to define a custom function that will be invoked automatically whenever an authentication process fails. This comes in handy when you need to record every login attempt, whether it is successful or not.
To start with, you have to create a database table that will be used to store audit records...