File indexing completed on 2024-12-22 05:36:37

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_EventManager
0017  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0018  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0019  */
0020 
0021 // require_once 'Zend/Stdlib/CallbackHandler.php';
0022 
0023 /**
0024  * Interface for messengers
0025  *
0026  * @category   Zend
0027  * @package    Zend_EventManager
0028  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0029  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0030  */
0031 interface Zend_EventManager_EventCollection
0032 {
0033     /**
0034      * Trigger an event
0035      *
0036      * Should allow handling the following scenarios:
0037      * - Passing Event object only
0038      * - Passing event name and Event object only
0039      * - Passing event name, target, and Event object
0040      * - Passing event name, target, and array|ArrayAccess of arguments
0041      *
0042      * Can emulate triggerUntil() if the last argument provided is a callback.
0043      * 
0044      * @param  string $event 
0045      * @param  object|string $target 
0046      * @param  array|object $argv 
0047      * @param  null|callback $callback 
0048      * @return Zend_EventManager_ResponseCollection
0049      */
0050     public function trigger($event, $target = null, $argv = array(), $callback = null);
0051 
0052     /**
0053      * Trigger an event until the given callback returns a boolean false
0054      *
0055      * Should allow handling the following scenarios:
0056      * - Passing Event object and callback only
0057      * - Passing event name, Event object, and callback only
0058      * - Passing event name, target, Event object, and callback
0059      * - Passing event name, target, array|ArrayAccess of arguments, and callback
0060      * 
0061      * @param  string $event 
0062      * @param  object|string $target 
0063      * @param  array|object $argv 
0064      * @param  callback $callback 
0065      * @return Zend_EventManager_ResponseCollection
0066      */
0067     public function triggerUntil($event, $target, $argv = null, $callback = null);
0068 
0069     /**
0070      * Attach a listener to an event
0071      * 
0072      * @param  string $event 
0073      * @param  callback $callback
0074      * @param  int $priority Priority at which to register listener
0075      * @return Zend_Stdlib_CallbackHandler
0076      */
0077     public function attach($event, $callback = null, $priority = 1);
0078 
0079     /**
0080      * Detach an event listener
0081      * 
0082      * @param  Zend_Stdlib_CallbackHandler|Zend_EventManager_ListenerAggregate $listener 
0083      * @return void
0084      */
0085     public function detach($listener);
0086 
0087     /**
0088      * Get a list of events for which this collection has listeners
0089      * 
0090      * @return array
0091      */
0092     public function getEvents();
0093 
0094     /**
0095      * Retrieve a list of listeners registered to a given event
0096      * 
0097      * @param  string $event 
0098      * @return array|object
0099      */
0100     public function getListeners($event);
0101 
0102     /**
0103      * Clear all listeners for a given event
0104      * 
0105      * @param  string $event 
0106      * @return void
0107      */
0108     public function clearListeners($event);
0109 }