EventManager/EventManager.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled
with this package in the file LICENSE.txt.
It is also available through the world-wide-web at this URL:
http://framework.zend.com/license/new-bsd
If you did not receive a copy of the license and are unable to
obtain it through the world-wide-web, please send an email
to
[email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_EventManager
\Zend_EventManager_EventManager
Package: Zend_EventManagerEvent manager: notification system
Use the EventManager when you want to create a per-instance notification
system for your objects.
- Implements
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Properties
string $eventClass = 'Zend_EventManager_Event'
Class representing the event being emitted
Default value'Zend_EventManager_Event'
Details- Type
- string
array $events = array()
Subscribed events and their listeners
Default valuearray()
Details- Type
- array
array $identifiers = array()
Identifiers, used to pull static signals from StaticEventManager
Default valuearray()
Details- Type
- array
Methods
attach(string | array | \Zend_EventManager_ListenerAggregate $event, callback | int $callback = null, int $priority = 1) : \Zend_Stdlib_CallbackHandler | mixed
Attach a listener to an event
The first argument is the event, and the next argument describes a
callback that will respond to that event. A CallbackHandler instance
describing the event listener combination will be returned.
The last argument indicates a priority at which the event should be
executed. By default, this value is 1; however, you may set it for any
integer value. Higher values have higher priority (i.e., execute first).
You can specify "*" for the event name. In such cases, the listener will
be triggered for every event.
ParametersName | Type | Description |
---|
$event | string | array | \Zend_EventManager_ListenerAggregate | An event or array of event names. If a ListenerAggregate, proxies to {@link attachAggregate()}. |
---|
$callback | callback | int | If string $event provided, expects PHP callback; for a ListenerAggregate $event, this will be the priority |
---|
$priority | int | If provided, the priority at which to register the callback |
---|
ReturnsType | Description |
---|
\Zend_Stdlib_CallbackHandler | mixed | CallbackHandler if attaching callback (to allow later unsubscribe); mixed if attaching aggregate |
attachAggregate(\Zend_EventManager_ListenerAggregate $aggregate, int $priority = 1) : mixed
Attach a listener aggregate
Listener aggregates accept an EventCollection instance, and call attach()
one or more times, typically to attach to multiple events using local
methods.
ParametersReturnsType | Description |
---|
mixed | return value of {@link Zend_EventManager_ListenerAggregate::attach()} |
clearListeners(string $event) : void
Clear all listeners for a given event
ParametersName | Type | Description |
---|
$event | string | |
---|
detachAggregate(\Zend_EventManager_ListenerAggregate $aggregate) : mixed
Detach a listener aggregate
Listener aggregates accept an EventCollection instance, and call detach()
of all previously attached listeners.
ParametersReturnsType | Description |
---|
mixed | return value of {@link Zend_EventManager_ListenerAggregate::detach()} |
getListeners(string $event) : \Zend_Stdlib_PriorityQueue
Retrieve all listeners for a given event
ParametersName | Type | Description |
---|
$event | string | |
---|
Returns getSharedListeners(string $event) : array
Get list of all listeners attached to the shared collection for
identifiers registered by this instance
ParametersName | Type | Description |
---|
$event | string | |
---|
Returns trigger(string $event, string | object $target = null, array | \ArrayAccess $argv = array(), null | callback $callback = null) : \Zend_EventManager_ResponseCollection
Trigger all listeners for a given event
Can emulate triggerUntil() if the last argument provided is a callback.
ParametersName | Type | Description |
---|
$event | string | |
---|
$target | string | object | Object calling emit, or symbol describing target (such as static method name) |
---|
$argv | array | \ArrayAccess | Array of arguments; typically, should be associative |
---|
$callback | null | callback | |
---|
ReturnstriggerUntil(string $event, string | object $target, array | \ArrayAccess $argv = null, Callable $callback = null) : void
Trigger listeners until return value of one causes a callback to
evaluate to true
Triggers listeners until the provided callback evaluates the return
value of one as true, or until all listeners have been executed.
ParametersName | Type | Description |
---|
$event | string | |
---|
$target | string | object | Object calling emit, or symbol describing target (such as static method name) |
---|
$argv | array | \ArrayAccess | Array of arguments; typically, should be associative |
---|
$callback | Callable | |
---|
ThrowsunsetSharedCollections() : void
Remove any shared collections
Sets {@link $sharedCollections} to boolean false to disable ability
to lazy-load static event manager instance.