Middlewares with string on class/function
This commit is contained in:
@@ -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)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user