Stud.IP  4.0
 All Data Structures Namespaces Files Functions Variables Groups
NotificationCenter Class Reference

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)
 
static on ($event, Callable $callback, $object=null)
 
static off ($event, Callable $callback, $object=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). The event name may contain shell-style wildcards (like '*').

Parameters
object$observerobject to be notified
string$methodmethod that will be called
string$eventname of event (may be NULL)
mixed$objectsubject to observe (may be NULL)
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
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
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$eventname of this notification
mixed$objectsubject of this notification
mixed$user_dataadditional information (optional)
Exceptions
NotificationVetoExceptionon observer veto
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$observerobject to be removed
string$eventname of event (may be NULL)
mixed$objectsubject to observe (may be NULL)

The documentation for this class was generated from the following file: