File tree Expand file tree Collapse file tree 3 files changed +54
-6
lines changed Expand file tree Collapse file tree 3 files changed +54
-6
lines changed Original file line number Diff line number Diff line change @@ -299,12 +299,8 @@ protected function childFactory($name)
299299 $ class = '\\Bitbucket \\API \\' .$ name ;
300300 $ child = new $ class ($ this ->client );
301301
302- if ($ this ->getClient ()->isListener ('basicauth ' )) {
303- $ child ->getClient ()->addListener ($ this ->getClient ()->getListener ('basicauth ' ));
304- }
305-
306- if ($ this ->getClient ()->isListener ('oauth ' )) {
307- $ child ->getClient ()->addListener ($ this ->getClient ()->getListener ('oauth ' ));
302+ if ($ this ->getClient ()->hasListeners ()) {
303+ $ child ->getClient ()->setListeners ($ this ->getClient ()->getListeners ());
308304 }
309305
310306 return $ child ;
Original file line number Diff line number Diff line change @@ -149,6 +149,25 @@ public function delListener($name);
149149 */
150150 public function getListener ($ name );
151151
152+ /**
153+ * @access public
154+ * @return array
155+ */
156+ public function getListeners ();
157+
158+ /**
159+ * @access public
160+ * @return bool
161+ */
162+ public function hasListeners ();
163+
164+ /**
165+ * @access public
166+ * @param array $listeners
167+ * @return $this
168+ */
169+ public function setListeners (array $ listeners );
170+
152171 /**
153172 * Check if a listener exists
154173 *
Original file line number Diff line number Diff line change @@ -76,6 +76,39 @@ public function isListener($name)
7676 return ($ this ->searchListener ($ name ) instanceof ListenerInterface);
7777 }
7878
79+ /**
80+ * @access public
81+ * @return array
82+ */
83+ public function getListeners ()
84+ {
85+ return $ this ->listeners ;
86+ }
87+
88+ /**
89+ * @access public
90+ * @return bool
91+ */
92+ public function hasListeners ()
93+ {
94+ return (count ($ this ->listeners ) > 0 );
95+ }
96+
97+ /**
98+ * @access public
99+ * @param array $listeners
100+ * @return $this;
101+ */
102+ public function setListeners (array $ listeners )
103+ {
104+ foreach ($ listeners as $ prio => $ listener ) {
105+ $ listener = array_values ($ listener );
106+ $ this ->addListener ($ listener [0 ], $ prio );
107+ }
108+
109+ return $ this ;
110+ }
111+
79112 /**
80113 * @access protected
81114 * @param string $name Listener name
You can’t perform that action at this time.
0 commit comments