Skip to content

Commit

Permalink
Update Route.php
Browse files Browse the repository at this point in the history
  • Loading branch information
walkor authored Nov 1, 2020
1 parent 7b614e2 commit d5057ec
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,17 @@ public static function dispatch($method, $path)
*/
public static function convertToCallable($path, $callback)
{
if (\is_callable($callback)) return $callback;
$callback = explode('@', $callback);
if (isset($callback[0]) && isset($callback[1]) && \class_exists($callback[0]) && \is_callable([App::container()->get($callback[0]), $callback[1]])) {
if (\is_array($callback)) {
$callback = \array_values($callback);
}
if (\is_callable($callback)) {
if (\is_array($callback) && \is_string($callback[0])) {
return [App::container()->get($callback[0]), $callback[1]];
}
return $callback;
}
$callback = \explode('@', $callback);
if (isset($callback[1]) && \class_exists($callback[0]) && \is_callable([App::container()->get($callback[0]), $callback[1]])) {
return [App::container()->get($callback[0]), $callback[1]];
}
echo "Route set to $path is not callable\n";
Expand Down

0 comments on commit d5057ec

Please sign in to comment.