This commit is contained in:
as2252258@163.com
2021-04-09 03:03:41 +08:00
parent 392d21de55
commit 263c2d6925
+9 -5
View File
@@ -7,11 +7,11 @@ namespace HttpServer\Events;
class Pipeline class Pipeline
{ {
private \Closure $_if; private ?\Closure $_if = null;
private \Closure $_else; private ?\Closure $_else = null;
private \Closure $_catch; private ?\Closure $_catch = null;
private \Closure $_after; private ?\Closure $_after = null;
private \Closure $_before; private ?\Closure $_before = null;
private bool $condition; private bool $condition;
@@ -78,7 +78,9 @@ class Pipeline
public function exec(...$argv) public function exec(...$argv)
{ {
try { try {
if ($this->_before instanceof \Closure) {
call_user_func($this->_before, ...$argv); call_user_func($this->_before, ...$argv);
}
if ($this->condition !== true) { if ($this->condition !== true) {
call_user_func($this->_else, ...$argv); call_user_func($this->_else, ...$argv);
} else { } else {
@@ -89,8 +91,10 @@ class Pipeline
call_user_func($this->_catch, $exception); call_user_func($this->_catch, $exception);
return $argv; return $argv;
} finally { } finally {
if ($this->_after instanceof \Closure) {
call_user_func($this->_after, ...$argv); call_user_func($this->_after, ...$argv);
} }
} }
}
} }