|
static | addObserver ($observer, $method, $event, $object=NULL) |
|
static | removeObserver ($observer, $event=NULL, $object=NULL) |
|
static | postNotification ($event, $object, $user_data=null) |
|
static | on ($event, Callable $callback, $object=null) |
|
static | off ($event, Callable $callback, $object=null) |
|
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);
◆ addObserver()
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). The event name may contain shell-style wildcards (like '*').
- 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) |
◆ off()
static off |
( |
|
$event, |
|
|
Callable |
$callback, |
|
|
|
$object = null |
|
) |
| |
|
static |
Convenience method that uses a jQuery like structure for event unregistration by closures.
- Parameters
-
string | $event | |
Callable | $callback | |
mixed | $object | |
- Since
- Stud.IP 4.2
◆ on()
static on |
( |
|
$event, |
|
|
Callable |
$callback, |
|
|
|
$object = null |
|
) |
| |
|
static |
Convenience method that uses a jQuery like structure for event registration by closures.
- Parameters
-
string | $event | |
Callable | $callback | |
mixed | $object | |
- Since
- Stud.IP 4.2
◆ postNotification()
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
-
◆ removeObserver()
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: