forked from zendframework/zendframework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EventManagerInterface.php
144 lines (129 loc) · 4.13 KB
/
EventManagerInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\EventManager;
use Traversable;
use Zend\Stdlib\CallbackHandler;
/**
* Interface for messengers
*/
interface EventManagerInterface extends SharedEventManagerAwareInterface
{
/**
* Trigger an event
*
* Should allow handling the following scenarios:
* - Passing Event object only
* - Passing event name and Event object only
* - Passing event name, target, and Event object
* - Passing event name, target, and array|ArrayAccess of arguments
*
* Can emulate triggerUntil() if the last argument provided is a callback.
*
* @param string $event
* @param object|string $target
* @param array|object $argv
* @param null|callable $callback
* @return ResponseCollection
*/
public function trigger($event, $target = null, $argv = array(), $callback = null);
/**
* Trigger an event until the given callback returns a boolean false
*
* Should allow handling the following scenarios:
* - Passing Event object and callback only
* - Passing event name, Event object, and callback only
* - Passing event name, target, Event object, and callback
* - Passing event name, target, array|ArrayAccess of arguments, and callback
*
* @param string $event
* @param object|string $target
* @param array|object $argv
* @param callable $callback
* @return ResponseCollection
*/
public function triggerUntil($event, $target, $argv = null, $callback = null);
/**
* Attach a listener to an event
*
* @param string $event
* @param callable $callback
* @param int $priority Priority at which to register listener
* @return CallbackHandler
*/
public function attach($event, $callback = null, $priority = 1);
/**
* Detach an event listener
*
* @param CallbackHandler|ListenerAggregateInterface $listener
* @return bool
*/
public function detach($listener);
/**
* Get a list of events for which this collection has listeners
*
* @return array
*/
public function getEvents();
/**
* Retrieve a list of listeners registered to a given event
*
* @param string $event
* @return array|object
*/
public function getListeners($event);
/**
* Clear all listeners for a given event
*
* @param string $event
* @return void
*/
public function clearListeners($event);
/**
* Set the event class to utilize
*
* @param string $class
* @return EventManagerInterface
*/
public function setEventClass($class);
/**
* Get the identifier(s) for this EventManager
*
* @return array
*/
public function getIdentifiers();
/**
* Set the identifiers (overrides any currently set identifiers)
*
* @param string|int|array|Traversable $identifiers
* @return EventManagerInterface
*/
public function setIdentifiers($identifiers);
/**
* Add some identifier(s) (appends to any currently set identifiers)
*
* @param string|int|array|Traversable $identifiers
* @return EventManagerInterface
*/
public function addIdentifiers($identifiers);
/**
* Attach a listener aggregate
*
* @param ListenerAggregateInterface $aggregate
* @param int $priority If provided, a suggested priority for the aggregate to use
* @return mixed return value of {@link ListenerAggregateInterface::attach()}
*/
public function attachAggregate(ListenerAggregateInterface $aggregate, $priority = 1);
/**
* Detach a listener aggregate
*
* @param ListenerAggregateInterface $aggregate
* @return mixed return value of {@link ListenerAggregateInterface::detach()}
*/
public function detachAggregate(ListenerAggregateInterface $aggregate);
}