\Horde_Notification_Handler

The Horde_Notification package provides a subject-observer pattern for raising and showing messages of different types and to different listeners.

Summary

Methods
Properties
Constants
__construct()
attach()
detach()
clear()
get()
getListener()
addType()
addDecorator()
push()
notify()
count()
No public properties found
No constants found
_addTypes()
$_decorators
$_forceAttach
$_handles
$_listeners
$_storage
N/A
No private methods found
No private properties found
N/A

Properties

$_decorators

$_decorators : array

Decorators.

Type

array

$_forceAttach

$_forceAttach : boolean

Forces immediate attachment of a notification to a listener.

Type

boolean

$_handles

$_handles : array

Additional handle definitions.

Type

array

$_listeners

$_listeners : array

Hash containing all attached listener objects.

Type

array

$_storage

$_storage : \Horde_Notification_Storage

The storage location where we store the messages.

Type

\Horde_Notification_Storage

Methods

__construct()

__construct(\Horde_Notification_Storage  $storage) 

Initialize the notification system.

Parameters

\Horde_Notification_Storage $storage

The storage object to use.

attach()

attach(string  $listener, array  $params = null, string  $class = null) : \Horde_Notification_Listener

Registers a listener with the notification object and includes the necessary library file dynamically.

Parameters

string $listener

The name of the listener to attach. These names must be unique; further listeners with the same name will be ignored.

array $params

A hash containing any additional configuration or connection parameters a listener driver might need.

string $class

The class name from which the driver was instantiated if not the default one. If given you have to include the library file containing this class yourself. This is useful if you want the listener driver to be overriden by an application's implementation

Throws

\Horde_Exception

Returns

\Horde_Notification_Listener

The listener object.

detach()

detach(  $listener) 

Remove a listener from the notification list.

Parameters

$listener

Throws

\Horde_Exception

clear()

clear(string  $listener = null) 

Clear any notification events that may exist in a listener.

Parameters

string $listener

The name of the listener to flush. If null, clears all unattached events.

get()

get(string  $type) : mixed

Returns the current Listener object for a given listener type.

Parameters

string $type

The listener type.

Returns

mixed —

A Horde_Notification_Listener object, or null if $type listener is not attached.

getListener()

getListener(string  $listener) : mixed

Returns a listener object given a listener name.

Parameters

string $listener

The listener name.

Returns

mixed —

Either a Horde_Notification_Listener or null.

addType()

addType(string  $listener, string  $type, string  $class) 

Adds a type handler to a given Listener.

To change the default listener, use the following:

  $ob->addType('default', '*', $classname);

Parameters

string $listener

The listener name.

string $type

The listener type.

string $class

The Event class to use.

push()

push(mixed  $event, string  $type = null, array  $flags = array(), array  $options = array()) 

Add an event to the Horde message stack.

Parameters

mixed $event

Horde_Notification_Event object or message string.

string $type

The type of message.

array $flags

Array of optional flags that will be passed to the registered listeners.

array $options

Additional options:

'immediate' - (boolean) If true, immediately tries to attach to a
              listener. If no listener exists for this type, the
              message will be dropped.
              DEFAULT: false (message will be attached to available
              handler at the time notify() is called).

notify()

notify(array  $options = array()) 

Passes the message stack to all listeners and asks them to handle their messages.

Parameters

array $options

An array containing display options for the listeners. Any options not contained in this list will be passed to the listeners.

listeners - (array) The list of listeners to notify.
raw - (boolean) If true, does not call the listener's notify()
      function.

count()

count(string  $my_listener = null) : integer

Return the number of notification messages in the stack.

Parameters

string $my_listener

The name of the listener.

Returns

integer —

The number of messages in the stack.

_addTypes()

_addTypes(string  $listener) 

Adds any additional listener types to a given Listener.

Parameters

string $listener

The listener name.