The Event_Dispatcher acts acts as a notification dispatch table.
It is used to notify other objects of interesting things, if
they meet certain criteria. This information is encapsulated
in {@link Event_Notification} objects. Client objects register
themselves with the Event_Dispatcher as observers of specific
notifications posted by other objects. When an event occurs,
an object posts an appropriate notification to the Event_Dispatcher.
The Event_Dispatcher dispatches a message to each
registered observer, passing the notification as the sole argument.
The Event_Dispatcher is actually a combination of three design
patterns: the Singleton, {@link http://c2.com/cgi/wiki?MediatorPattern Mediator},
and Observer patterns. The idea behind Event_Dispatcher is borrowed from
{@link http://developer.apple.com/documentation/Cocoa/Conceptual/Notifications/index.html Apple's Cocoa framework}.
The purpose of the optional associated object is generally to pass
the object posting the notification to the observers, so that the
observers can query the posting object for more information about
the event.
Notifications are by default added to a pending notification list.
This way, if an observer is not registered by the time they are
posted, it will still be notified when it is added as an observer.
This behaviour can be turned off in order to make sure that only
the registered observers will be notified.
The info array serves as a container for any kind of useful
information. It is added to the notification object and posted along.
public post ( &$object, $nName, $info = [], $pending = true, $bubble = true ) : object |
Résultat |
object |
The notification object |
postNotification()
public méthode
Posts the {@link Event_Notification} object