1 | <?php |
||
32 | trait ListenerAwareTrait |
||
33 | { |
||
34 | /** |
||
35 | * {@inheritDoc} |
||
36 | */ |
||
37 | public function attachListener(ListenerInterface $listener) |
||
54 | |||
55 | /** |
||
56 | * {@inheritDoc} |
||
57 | */ |
||
58 | public function detachListener( |
||
74 | |||
75 | /** |
||
76 | * standardize events definition |
||
77 | * |
||
78 | * @param ListenerInterface $listener |
||
79 | * @return array |
||
80 | * @access protected |
||
81 | */ |
||
82 | protected function listenerEvents( |
||
96 | |||
97 | /** |
||
98 | * standardize to array of 'method1' or ['method1', 20] |
||
99 | * |
||
100 | * @param mixed $data |
||
101 | * @return array |
||
102 | * @access protected |
||
103 | */ |
||
104 | protected function expandToHandler($data)/*# : array */ |
||
117 | |||
118 | /** |
||
119 | * standardize one 'method1' or ['method1', 20, $scope] |
||
120 | * to [eventName, callable, priority, $scopeIfAny] |
||
121 | * |
||
122 | * @param ListenerInterface $listener |
||
123 | * @param string $eventName |
||
124 | * @param mixed $data |
||
125 | * @return array |
||
126 | * @access protected |
||
127 | */ |
||
128 | protected function expandWithPriority( |
||
144 | |||
145 | /** |
||
146 | * standardize 'method' or callable to callable |
||
147 | * |
||
148 | * @param ListenerInterface $listener |
||
149 | * @param mixed $callable |
||
150 | * @return callable |
||
151 | * @access protected |
||
152 | */ |
||
153 | protected function expandCallable( |
||
163 | |||
164 | /** |
||
165 | * off listener event [$eventName, $handler, $priority, $scope] |
||
166 | * |
||
167 | * @param array $data |
||
168 | * @access protected |
||
169 | */ |
||
170 | protected function offListenerEvent(array $data) |
||
181 | |||
182 | // from other trait |
||
183 | abstract public function on(/*# string */ $eventName, callable $callable, /*# int */ $priority = 50); |
||
185 | } |
||
186 |