From 2d6227824c5562c416715d0ad32ddafc566e6755 Mon Sep 17 00:00:00 2001 From: ahwelp Date: Wed, 13 Mar 2019 06:00:57 +0000 Subject: [PATCH] Accepting String as callback --- src/BBRouter/Route.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/BBRouter/Route.php b/src/BBRouter/Route.php index 3ba6159..30ed1b3 100755 --- a/src/BBRouter/Route.php +++ b/src/BBRouter/Route.php @@ -146,7 +146,13 @@ class Route{ } foreach ($this->_callback as $callback){ - call_user_func_array($callback, $this->_params); + if(is_string($callback)){ + $segments = explode('@', $callback); + $class = new $segments[0](); + $class->{$segments[1]}(...array_values($this->_params)); + }else{ + call_user_func_array($callback, $this->_params); + } } foreach ($this->_after as $after){ @@ -255,7 +261,4 @@ class Route{ return false; } -} - - - +} \ No newline at end of file