1 | <?php |
||
14 | class CallableListener implements ListenerInterface |
||
15 | { |
||
16 | /** |
||
17 | * The callable callback. |
||
18 | * |
||
19 | * @var callable |
||
20 | */ |
||
21 | protected $callable; |
||
22 | |||
23 | /** |
||
24 | * Array of callable-listeners. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected static $listeners = []; |
||
29 | |||
30 | public function __construct($callable) |
||
35 | |||
36 | /** |
||
37 | * Gets callback. |
||
38 | * |
||
39 | * @return callable |
||
40 | */ |
||
41 | public function getCallable() |
||
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | public function handle(Event $event) |
||
53 | |||
54 | /** |
||
55 | * Creates a callable-listener. |
||
56 | * |
||
57 | * @param callable $callable |
||
58 | * |
||
59 | * @return CallableListener |
||
60 | */ |
||
61 | public static function createFromCallable($callable) |
||
67 | |||
68 | /** |
||
69 | * Finds the listener from the collection by its callable. |
||
70 | * |
||
71 | * @param callable $callable |
||
72 | * |
||
73 | * @return CallableListener|false |
||
74 | */ |
||
75 | public static function findByCallable($callable) |
||
85 | |||
86 | /** |
||
87 | * Removes all registered callable-listeners. |
||
88 | */ |
||
89 | public static function clearListeners() |
||
93 | } |
||
94 |