EventManager/EventManager.php

Show: PublicProtectedPrivateinherited
Table of Contents
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 license@zend.com 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_EventManager
Event 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

>VPropertyprotectedstring $eventClass = 'Zend_EventManager_Event'

Class representing the event being emitted

Default value'Zend_EventManager_Event'Details
Type
string
>VPropertyprotectedarray $events = array()
Subscribed events and their listeners
Default valuearray()Details
Type
array
>VPropertyprotectedarray $identifiers = array()
Identifiers, used to pull static signals from StaticEventManager
Default valuearray()Details
Type
array
>VPropertyprotectedfalse|null|\Zend_EventManager_StaticEventCollection $sharedCollections = null
Static collections
Default valuenullDetails
Type
false | null | \Zend_EventManager_StaticEventCollection

Methods

methodpublic__construct(null | string | int | array | \Traversable $identifiers = null) : void

Constructor

Allows optionally specifying identifier(s) to use to pull signals from a StaticEventManager.
Parameters
NameTypeDescription
$identifiersnull | string | int | array | \Traversable
methodpublicaddIdentifiers(string | int | array | \Traversable $identifiers) : \Zend_EventManager_EventManager

Add some identifier(s) (appends to any currently set identifiers)

Parameters
NameTypeDescription
$identifiersstring | int | array | \Traversable
Returns
TypeDescription
\Zend_EventManager_EventManager
methodpublicattach(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.
Parameters
NameTypeDescription
$eventstring | array | \Zend_EventManager_ListenerAggregate

An event or array of event names. If a ListenerAggregate, proxies to {@link attachAggregate()}.

$callbackcallback | int

If string $event provided, expects PHP callback; for a ListenerAggregate $event, this will be the priority

$priorityint

If provided, the priority at which to register the callback

Returns
TypeDescription
\Zend_Stdlib_CallbackHandler | mixedCallbackHandler if attaching callback (to allow later unsubscribe); mixed if attaching aggregate
methodpublicattachAggregate(\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.
Parameters
NameTypeDescription
$aggregate\Zend_EventManager_ListenerAggregate
$priorityint

If provided, a suggested priority for the aggregate to use

Returns
TypeDescription
mixedreturn value of {@link Zend_EventManager_ListenerAggregate::attach()}
methodpublicclearListeners(string $event) : void

Clear all listeners for a given event

Parameters
NameTypeDescription
$eventstring
methodpublicdetach(\Zend_Stdlib_CallbackHandler | \Zend_EventManager_ListenerAggregate $listener) : bool

Unsubscribe a listener from an event

Parameters
NameTypeDescription
$listener\Zend_Stdlib_CallbackHandler | \Zend_EventManager_ListenerAggregate
Returns
TypeDescription
boolReturns true if event and listener found, and unsubscribed; returns false if either event or listener not found
Throws
ExceptionDescription
\Zend_EventManager_Exception_InvalidArgumentExceptionif invalid listener provided
methodpublicdetachAggregate(\Zend_EventManager_ListenerAggregate $aggregate) : mixed

Detach a listener aggregate

Listener aggregates accept an EventCollection instance, and call detach() of all previously attached listeners.
Parameters
NameTypeDescription
$aggregate\Zend_EventManager_ListenerAggregate
Returns
TypeDescription
mixedreturn value of {@link Zend_EventManager_ListenerAggregate::detach()}
methodpublicgetEvents() : array

Retrieve all registered events

Returns
TypeDescription
array
methodpublicgetIdentifiers() : array

Get the identifier(s) for this Zend_EventManager_EventManager

Returns
TypeDescription
array
methodpublicgetListeners(string $event) : \Zend_Stdlib_PriorityQueue

Retrieve all listeners for a given event

Parameters
NameTypeDescription
$eventstring
Returns
TypeDescription
\Zend_Stdlib_PriorityQueue
methodpublicgetSharedCollections() : false | \Zend_EventManager_SharedEventCollection

Get static collections container

Returns
TypeDescription
false | \Zend_EventManager_SharedEventCollection
methodprotectedgetSharedListeners(string $event) : array

Get list of all listeners attached to the shared collection for identifiers registered by this instance

Parameters
NameTypeDescription
$eventstring
Returns
TypeDescription
array
methodprotectedinsertListeners(\Zend_Stdlib_PriorityQueue $masterListeners, \Zend_Stdlib_PriorityQueue $listeners) : void

Add listeners to the master queue of listeners

Used to inject shared listeners and wildcard listeners.
Parameters
NameTypeDescription
$masterListeners\Zend_Stdlib_PriorityQueue
$listeners\Zend_Stdlib_PriorityQueue
methodpublicprepareArgs(array $args) : \ArrayObject

Prepare arguments

Use this method if you want to be able to modify arguments from within a listener. It returns an ArrayObject of the arguments, which may then be passed to trigger() or triggerUntil().
Parameters
NameTypeDescription
$argsarray
Returns
TypeDescription
\ArrayObject
methodpublicsetEventClass(string $class) : \Zend_EventManager_EventManager

Set the event class to utilize

Parameters
NameTypeDescription
$classstring
Returns
TypeDescription
\Zend_EventManager_EventManager
methodpublicsetIdentifiers(string | int | array | \Traversable $identifiers) : \Zend_EventManager_EventManager

Set the identifiers (overrides any currently set identifiers)

Parameters
NameTypeDescription
$identifiersstring | int | array | \Traversable
Returns
TypeDescription
\Zend_EventManager_EventManager
methodpublicsetSharedCollections(\Zend_EventManager_StaticEventCollection $collections) : void

Set static collections container

Parameters
NameTypeDescription
$collections\Zend_EventManager_StaticEventCollection
methodpublictrigger(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.
Parameters
NameTypeDescription
$eventstring
$targetstring | object

Object calling emit, or symbol describing target (such as static method name)

$argvarray | \ArrayAccess

Array of arguments; typically, should be associative

$callbacknull | callback
Returns
TypeDescription
\Zend_EventManager_ResponseCollectionAll listener return values
methodprotectedtriggerListeners(string $event, \EventDescription $e, null | callback $callback = null) : \ResponseCollection

Trigger listeners

Actual functionality for triggering listeners, to which both trigger() and triggerUntil() delegate.
Parameters
NameTypeDescription
$eventstring

Event name

$e\EventDescription
$callbacknull | callback
Returns
TypeDescription
\ResponseCollection
methodpublictriggerUntil(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.
Parameters
NameTypeDescription
$eventstring
$targetstring | object

Object calling emit, or symbol describing target (such as static method name)

$argvarray | \ArrayAccess

Array of arguments; typically, should be associative

$callbackCallable
Throws
ExceptionDescription
\Zend_Stdlib_Exception_InvalidCallbackExceptionif invalid callback provided
methodpublicunsetSharedCollections() : void

Remove any shared collections

Sets {@link $sharedCollections} to boolean false to disable ability to lazy-load static event manager instance.
Documentation was generated by phpDocumentor 2.2.0 .