Zend Framework  1.12
Public Member Functions | Protected Attributes | List of all members
Zend_EventManager_SharedEventManager Class Reference

Public Member Functions

 attach ($id, $event, $callback, $priority=1)
 Attach a listener to an event.
 
 detach ($id, Zend_Stdlib_CallbackHandler $listener)
 Detach a listener from an event offered by a given resource.
 
 getEvents ($id)
 Retrieve all registered events for a given resource.
 
 getListeners ($id, $event)
 Retrieve all listeners for a given identifier and event.
 
 clearListeners ($id, $event=null)
 Clear all listeners for a given identifier, optionally for a specific event.
 

Protected Attributes

 $identifiers = array()
 

Member Function Documentation

attach (   $id,
  $event,
  $callback,
  $priority = 1 
)

Attach a listener to an event.

Allows attaching a callback to an event offerred by one or more identifying components. As an example, the following connects to the "getAll" event of both an AbstractResource and EntityResource:

SharedEventManager::getInstance()->connect( array('My', 'My'), 'getOne', function ($e) use ($cache) { if (!$id = $e->getParam('id', false)) { return; } if (!$data = $cache->load(get_class($resource) . '::getOne::' . $id )) { return; } return $data; } );

Parameters
string | array$idIdentifier(s) for event emitting component(s)
string$event
callback$callbackPHP Callback
int$priorityPriority at which listener should execute
Returns
void
clearListeners (   $id,
  $event = null 
)

Clear all listeners for a given identifier, optionally for a specific event.

Parameters
string | int$id
null | string$event
Returns
bool
detach (   $id,
Zend_Stdlib_CallbackHandler  $listener 
)

Detach a listener from an event offered by a given resource.

Parameters
string | int$id
Zend_Stdlib_CallbackHandler$listener
Returns
bool Returns true if event and listener found, and unsubscribed; returns false if either event or listener not found
getEvents (   $id)

Retrieve all registered events for a given resource.

Parameters
string | int$id
Returns
array
getListeners (   $id,
  $event 
)

Retrieve all listeners for a given identifier and event.

Parameters
string | int$id
string | int$event
Returns
false|Zend_Stdlib_PriorityQueue

Implements Zend_EventManager_SharedEventCollection.

Member Data Documentation

$identifiers = array()
protected