Skip to content

Commit

Permalink
Update Route.php
Browse files Browse the repository at this point in the history
  • Loading branch information
walkor authored May 7, 2021
1 parent 0a9e5b2 commit fe4d8c2
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,24 +246,23 @@ public static function dispatch($method, $path)
*/
public static function convertToCallable($path, $callback)
{
if (\is_string($callback) && \strpos($callback, '@')) {
$callback = \explode('@', $callback, 2);
}

if (\is_array($callback)) {
$callback = \array_values($callback);
}
if (\is_callable($callback, true)) {
if (\is_array($callback) && \is_string($callback[0])) {
return [App::container()->get($callback[0]), $callback[1]];
if (isset($callback[1]) && \is_string($callback[0]) && \class_exists($callback[0])) {
$callback = [App::container()->get($callback[0]), $callback[1]];
}
return $callback;
} else if (\is_array($callback)) {
}

if (!\is_callable($callback)) {
echo "Route set to $path is not callable\n";
return false;
}
$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";
return false;

return $callback;
}

/**
Expand Down

0 comments on commit fe4d8c2

Please sign in to comment.