1 | <?php |
||
36 | trait ListenerAwareTrait |
||
37 | { |
||
38 | /** |
||
39 | * {@inheritDoc} |
||
40 | */ |
||
41 | public function attachListener(ListenerInterface $listener)/*# : bool */ |
||
57 | |||
58 | /** |
||
59 | * {@inheritDoc} |
||
60 | */ |
||
61 | public function detachListener( |
||
77 | |||
78 | /** |
||
79 | * standardize events definition |
||
80 | * |
||
81 | * @param ListenerInterface $listener |
||
82 | * @return array |
||
83 | * @access protected |
||
84 | */ |
||
85 | protected function listenerEvents( |
||
101 | |||
102 | /** |
||
103 | * standardize to array of 'method1' or ['method1', 20] |
||
104 | * |
||
105 | * @param mixed $data |
||
106 | * @return array |
||
107 | * @access protected |
||
108 | */ |
||
109 | protected function expandToHandler($data)/*# : array */ |
||
122 | |||
123 | /** |
||
124 | * standardize one 'method1' or ['method1', 20, $scope] |
||
125 | * to [eventName, callable, priority, $scopeIfAny] |
||
126 | * |
||
127 | * @param ListenerInterface $listener |
||
128 | * @param string $eventName |
||
129 | * @param mixed $data |
||
130 | * @return array |
||
131 | * @access protected |
||
132 | */ |
||
133 | protected function expandWithPriority( |
||
149 | |||
150 | /** |
||
151 | * standardize 'method' or callable to callable |
||
152 | * |
||
153 | * @param ListenerInterface $listener |
||
154 | * @param mixed $callable |
||
155 | * @return callable |
||
156 | * @access protected |
||
157 | */ |
||
158 | protected function expandCallable( |
||
168 | |||
169 | /** |
||
170 | * off listener event [$eventName, $handler, $priority, $scope] |
||
171 | * |
||
172 | * @param array $data |
||
173 | * @access protected |
||
174 | */ |
||
175 | protected function offListenerEvent(array $data) |
||
184 | |||
185 | /** |
||
186 | * the second value is the priority value |
||
187 | * |
||
188 | * @param array $data |
||
189 | * @access protected |
||
190 | */ |
||
191 | protected function hasPriority(array $data)/*# : bool */ |
||
195 | } |
||
196 |