previousGet the name of the dispatcher. (Previous) (Next) Remove an observer.next

View this page in Last updated: Sun, 07 Feb 2010
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

Event_Dispatcher::addObserver

Event_Dispatcher::addObserver() – Add a new observer.

Synopsis

require_once 'Event/Dispatcher.php';

void Event_Dispatcher::addObserver ( mixed $callback , string $nName = EVENT_DISPATCHER_GLOBAL , string $class = '' )

Description

Adds a new observer to the dispatcher.

Observers are PHP callbacks. That means you may either pass a function name as a string or an array containing an object or class and a method to call.

The callback is used as a signature for the observer, which allows you to remove it by passing the exact same parameters to removeObserver().

Parameter

  • mixed $callback

    Callback to notity, may either be a string containing the name of a global function or an array containing class or object and the name of the method to call.

  • string $nName = EVENT_DISPATCHER_GLOBAL

    Acts as a filter: notify the observer only if the notification name matches the name passed in this parameter. Use EVENT_DISPATCHER_GLOBAL if the observer should be notified regardles of the notification name.

  • string $class = ''

    Acts as a filter: notify the observer only if the sender of the notification matches the class passed in this parameter.

Return value

void

Note

This function can not be called statically.

previousGet the name of the dispatcher. (Previous) (Next) Remove an observer.next

Download Documentation Last updated: Sun, 07 Feb 2010
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.