/
EventDispatcherInterface.php
89 lines (80 loc) · 2.54 KB
/
EventDispatcherInterface.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
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\EventDispatcher;
/**
* EventDispatcherInterface describes an event dispatcher class.
*
* @see http://developer.apple.com/documentation/Cocoa/Conceptual/Notifications/index.html Apple's Cocoa framework
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
interface EventDispatcherInterface
{
/**
* Connects a listener to a given event name.
*
* Listeners with a higher priority are executed first.
*
* @param string $name An event name
* @param mixed $listener A PHP callable
* @param integer $priority The priority (between -10 and 10 -- defaults to 0)
*/
function connect($name, $listener, $priority = 0);
/**
* Disconnects one, or all listeners for the given event name.
*
* @param string $name An event name
* @param mixed|null $listener The listener to remove, or null to remove all
*
* @return void
*/
function disconnect($name, $listener = null);
/**
* Notifies all listeners of a given event.
*
* @param EventInterface $event An EventInterface instance
*
* @return EventInterface The EventInterface instance
*/
function notify(EventInterface $event);
/**
* Notifies all listeners of a given event until one returns a non null value.
*
* @param EventInterface $event An EventInterface instance
*
* @return EventInterface The EventInterface instance
*/
function notifyUntil(EventInterface $event);
/**
* Filters a value by calling all listeners of a given event.
*
* @param EventInterface $event An EventInterface instance
* @param mixed $value The value to be filtered
*
* @return EventInterface The EventInterface instance
*/
function filter(EventInterface $event, $value);
/**
* Returns true if the given event name has some listeners.
*
* @param string $name The event name
*
* @return Boolean true if some listeners are connected, false otherwise
*/
function hasListeners($name);
/**
* Returns all listeners associated with a given event name.
*
* @param string $name The event name
*
* @return array An array of listeners
*/
function getListeners($name);
}