|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_EventManager |
|
17 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
|
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
19 */ |
|
20 |
|
21 require_once 'Zend/Stdlib/CallbackHandler.php'; |
|
22 |
|
23 /** |
|
24 * Interface for messengers |
|
25 * |
|
26 * @category Zend |
|
27 * @package Zend_EventManager |
|
28 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
|
29 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
30 */ |
|
31 interface Zend_EventManager_EventCollection |
|
32 { |
|
33 /** |
|
34 * Trigger an event |
|
35 * |
|
36 * Should allow handling the following scenarios: |
|
37 * - Passing Event object only |
|
38 * - Passing event name and Event object only |
|
39 * - Passing event name, target, and Event object |
|
40 * - Passing event name, target, and array|ArrayAccess of arguments |
|
41 * |
|
42 * Can emulate triggerUntil() if the last argument provided is a callback. |
|
43 * |
|
44 * @param string $event |
|
45 * @param object|string $target |
|
46 * @param array|object $argv |
|
47 * @param null|callback $callback |
|
48 * @return Zend_EventManager_ResponseCollection |
|
49 */ |
|
50 public function trigger($event, $target = null, $argv = array(), $callback = null); |
|
51 |
|
52 /** |
|
53 * Trigger an event until the given callback returns a boolean false |
|
54 * |
|
55 * Should allow handling the following scenarios: |
|
56 * - Passing Event object and callback only |
|
57 * - Passing event name, Event object, and callback only |
|
58 * - Passing event name, target, Event object, and callback |
|
59 * - Passing event name, target, array|ArrayAccess of arguments, and callback |
|
60 * |
|
61 * @param string $event |
|
62 * @param object|string $target |
|
63 * @param array|object $argv |
|
64 * @param callback $callback |
|
65 * @return Zend_EventManager_ResponseCollection |
|
66 */ |
|
67 public function triggerUntil($event, $target, $argv = null, $callback = null); |
|
68 |
|
69 /** |
|
70 * Attach a listener to an event |
|
71 * |
|
72 * @param string $event |
|
73 * @param callback $callback |
|
74 * @param int $priority Priority at which to register listener |
|
75 * @return Zend_Stdlib_CallbackHandler |
|
76 */ |
|
77 public function attach($event, $callback = null, $priority = 1); |
|
78 |
|
79 /** |
|
80 * Detach an event listener |
|
81 * |
|
82 * @param Zend_Stdlib_CallbackHandler|Zend_EventManager_ListenerAggregate $listener |
|
83 * @return void |
|
84 */ |
|
85 public function detach($listener); |
|
86 |
|
87 /** |
|
88 * Get a list of events for which this collection has listeners |
|
89 * |
|
90 * @return array |
|
91 */ |
|
92 public function getEvents(); |
|
93 |
|
94 /** |
|
95 * Retrieve a list of listeners registered to a given event |
|
96 * |
|
97 * @param string $event |
|
98 * @return array|object |
|
99 */ |
|
100 public function getListeners($event); |
|
101 |
|
102 /** |
|
103 * Clear all listeners for a given event |
|
104 * |
|
105 * @param string $event |
|
106 * @return void |
|
107 */ |
|
108 public function clearListeners($event); |
|
109 } |