-
Notifications
You must be signed in to change notification settings - Fork 8
Support single action controller, resource class and make routes availability configurable from env #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/laravel-data-v4
Are you sure you want to change the base?
Support single action controller, resource class and make routes availability configurable from env #1
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |||
| use Illuminate\Http\Response as HttpResponse; | ||||
| use Illuminate\Routing\Route; | ||||
| use Illuminate\Support\Collection; | ||||
| use Illuminate\Support\Str; | ||||
| use ReflectionClass; | ||||
| use ReflectionFunction; | ||||
| use ReflectionMethod; | ||||
|
|
@@ -36,7 +37,7 @@ public static function fromRoute(Route $route, string $method): self | |||
|
|
||||
| if (is_string($uses)) { | ||||
| $controller_class = new ReflectionClass($route->getController()); | ||||
| $controller_function = $controller_class->getMethod($route->getActionMethod()); | ||||
| $controller_function = $controller_class->getMethod(Str::parseCallback($route->action['uses'])[1]); | ||||
|
||||
|
|
||||
| echo $controller_class->name, "::", $controller_function->name, "\n"; | ||||
|
||||
| echo $controller_class->name, "::", $controller_function->name, "\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For single action controllers (invokable controllers),
Str::parseCallback($route->action['uses'])may return[class, null]if the action doesn't contain an '@' separator. Accessing[1]could givenull, causinggetMethod(null)to fail.Consider using
Str::parseCallback($route->action['uses'], '__invoke')[1]to provide a default method name for invokable controllers. Alternatively,$route->getActionMethod()already handles both regular and invokable controllers correctly.