Skip to content

Commit dca5a51

Browse files
committed
Can merge a pipe into another
1 parent 07216c7 commit dca5a51

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/WaterPipe/WaterPipe.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,20 @@ public function use($plugin)
8383
array_push($this->_middlewareRegistry, $plugin);
8484
} elseif ($plugin instanceof Route) {
8585
foreach (array("request", "get", "post", "put", "delete") as $method) {
86-
call_user_func_array(array($this, $method), array($plugin->getUri(), array($plugin, $method)));
86+
$this->$method($plugin->getUri(), array($plugin, $method));
87+
}
88+
} elseif ($plugin instanceof WaterPipe) {
89+
foreach (array(
90+
"request" => $plugin->_requestRegistry,
91+
"get" => $plugin->_getRequestRegistry,
92+
"post" => $plugin->_postRequestRegistry,
93+
"put" => $plugin->_putRequestRegistry,
94+
"delete" => $plugin->_deleteRequestRegistry) as $method => $registry) {
95+
96+
foreach ($registry as $uri => $action) {
97+
$this->$method($uri, $action);
98+
}
99+
87100
}
88101
}
89102
}

0 commit comments

Comments
 (0)