Middlewares with string on class/function

This commit is contained in:
2020-10-06 21:27:16 -03:00
parent 2c1d01abea
commit 47a08f5d49
+7
View File
@@ -137,11 +137,18 @@ class Route {
//======================================================= //=======================================================
function execute() { function execute() {
//Middlewares with function or class method
foreach ($this->_before as $key => $before) { foreach ($this->_before as $key => $before) {
if (!in_array($key, $this->_middlewaresToIgnore) && !$this->_ignore) { if (!in_array($key, $this->_middlewaresToIgnore) && !$this->_ignore) {
if (is_string($before)) {
$before = explode('@', $before);
$class = new $before[0]();
$class->{$before[1]}();
}else{
call_user_func($before); call_user_func($before);
} }
} }
}
foreach ($this->_callback as $callback) { foreach ($this->_callback as $callback) {
if (is_string($callback)) { if (is_string($callback)) {