Static Public Member Functions |
static | addObserver ($observer, $method, $event, $object=NULL) |
static | removeObserver ($observer, $event=NULL, $object=NULL) |
static | postNotification ($event, $object, $user_data=NULL) |
Detailed Description
The NotificationCenter class is the central event dispatcher for Stud.IP. Objects interested in receiving notifications for particular events need to register with the NotificationCenter:
NotificationCenter::addObserver($this, 'update', 'shutdown');
Event notifications are sent via the postNotification() method:
NotificationCenter::postNotification('shutdown', $sender);
Member Function Documentation
static addObserver |
( |
|
$observer, |
|
|
|
$method, |
|
|
|
$event, |
|
|
|
$object = NULL |
|
) |
| |
|
static |
Register an object to be notified. The same object may be registered several times (e.g. for different notifications).
- Parameters
-
object | $observer | object to be notified |
string | $method | method that will be called |
string | $event | name of event (may be NULL) |
mixed | $object | subject to observe (may be NULL) |
static postNotification |
( |
|
$event, |
|
|
|
$object, |
|
|
|
$user_data = NULL |
|
) |
| |
|
static |
Post an event notification to all registered observers. Only observers registered for this event type and subject are notified.
- Parameters
-
string | $event | name of this notification |
mixed | $object | subject of this notification |
mixed | $user_data | additional information (optional) |
- Exceptions
-
static removeObserver |
( |
|
$observer, |
|
|
|
$event = NULL , |
|
|
|
$object = NULL |
|
) |
| |
|
static |
Remove an object registered with the NotificationCenter. Trying to remove an observer that was not registered is allowed and has no effect.
- Parameters
-
object | $observer | object to be removed |
string | $event | name of event (may be NULL) |
mixed | $object | subject to observe (may be NULL) |
The documentation for this class was generated from the following file: