Skip to content

Commit 5aee967

Browse files
committed
cleaning up code
1 parent e9b3c18 commit 5aee967

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

src/Illuminate/Foundation/Console/RouteCacheCommand.php

+15-7
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ public function fire()
5858
return $this->error("Your application doesn't have any routes.");
5959
}
6060

61-
$routes->refreshNameLookups();
62-
$routes->refreshActionLookups();
63-
6461
foreach ($routes as $route) {
6562
$route->prepareForSerialization();
6663
}
@@ -79,11 +76,22 @@ public function fire()
7976
*/
8077
protected function getFreshApplicationRoutes()
8178
{
82-
$app = require $this->laravel->bootstrapPath().'/app.php';
83-
84-
$app->make(ConsoleKernelContract::class)->bootstrap();
79+
return tap($this->getFreshApplication()['router']->getRoutes(), function ($routes) {
80+
$routes->refreshNameLookups();
81+
$routes->refreshActionLookups();
82+
});
83+
}
8584

86-
return $app['router']->getRoutes();
85+
/**
86+
* Get a fresh application instance.
87+
*
88+
* @return \Illuminate\Foundation\Application
89+
*/
90+
protected function getFreshApplication()
91+
{
92+
return tap(require $this->laravel->bootstrapPath().'/app.php', function ($app) {
93+
$app->make(ConsoleKernelContract::class)->bootstrap();
94+
});
8795
}
8896

8997
/**

src/Illuminate/Routing/RouteCollection.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function refreshNameLookups()
131131
/**
132132
* Refresh the action look-up table.
133133
*
134-
* This is done in case any actions are fluently defined or if routes are overwritten.
134+
* This is done in case any actions are overwritten with new controllers.
135135
*
136136
* @return void
137137
*/
@@ -140,9 +140,8 @@ public function refreshActionLookups()
140140
$this->actionList = [];
141141

142142
foreach ($this->allRoutes as $route) {
143-
$action = $route->getAction();
144-
if (isset($action['controller'])) {
145-
$this->addToActionList($action, $route);
143+
if (isset($route->getAction()['controller'])) {
144+
$this->addToActionList($route->getAction(), $route);
146145
}
147146
}
148147
}

0 commit comments

Comments
 (0)