Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/Illuminate/Foundation/Console/RouteListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,7 @@ protected function isVendorRoute(Route $route)
*/
protected function isFrameworkController(Route $route)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably drop this method and just use $this->router->isFrameworkController((string) $route->getControllerClass()) directly, but I didn't want to introduce this potential breaking change since it's a protected method in a non final class

{
return in_array($route->getControllerClass(), [
'\Illuminate\Routing\RedirectController',
'\Illuminate\Routing\ViewController',
], true);
return $this->router->isFrameworkController((string) $route->getControllerClass());
}

/**
Expand Down
22 changes: 20 additions & 2 deletions src/Illuminate/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public function fallback($action)
*/
public function redirect($uri, $destination, $status = 302)
{
return $this->any($uri, '\Illuminate\Routing\RedirectController')
return $this->any($uri, RedirectController::class)
->defaults('destination', $destination)
->defaults('status', $status);
}
Expand Down Expand Up @@ -287,7 +287,7 @@ public function permanentRedirect($uri, $destination)
*/
public function view($uri, $view, $data = [], $status = 200, array $headers = [])
{
return $this->match(['GET', 'HEAD'], $uri, '\Illuminate\Routing\ViewController')
return $this->match(['GET', 'HEAD'], $uri, ViewController::class)
->setDefaults([
'view' => $view,
'data' => $data,
Expand Down Expand Up @@ -627,6 +627,10 @@ protected function convertToControllerAction($action)
*/
protected function prependGroupNamespace($class)
{
if ($this->isFrameworkController($class)) {
return '\\'.$class;
}

$group = end($this->groupStack);

return isset($group['namespace']) && ! str_starts_with($class, '\\') && ! str_starts_with($class, $group['namespace'])
Expand Down Expand Up @@ -1429,6 +1433,20 @@ public function setRoutes(RouteCollection $routes)
$this->container->instance('routes', $this->routes);
}

/**
* Determine if the class is a framework controller.
*
* @param string $class
* @return bool
*/
public function isFrameworkController($class)
{
return in_array($class, [
RedirectController::class,
ViewController::class,
], true);
}

/**
* Set the compiled route collection instance.
*
Expand Down