Skip to content

Commit

Permalink
cleaning up code
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 25, 2017
1 parent e9b3c18 commit 5aee967
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
22 changes: 15 additions & 7 deletions src/Illuminate/Foundation/Console/RouteCacheCommand.php
Expand Up @@ -58,9 +58,6 @@ public function fire()
return $this->error("Your application doesn't have any routes.");
}

$routes->refreshNameLookups();
$routes->refreshActionLookups();

foreach ($routes as $route) {
$route->prepareForSerialization();
}
Expand All @@ -79,11 +76,22 @@ public function fire()
*/
protected function getFreshApplicationRoutes()
{
$app = require $this->laravel->bootstrapPath().'/app.php';

$app->make(ConsoleKernelContract::class)->bootstrap();
return tap($this->getFreshApplication()['router']->getRoutes(), function ($routes) {
$routes->refreshNameLookups();
$routes->refreshActionLookups();
});
}

return $app['router']->getRoutes();
/**
* Get a fresh application instance.
*
* @return \Illuminate\Foundation\Application
*/
protected function getFreshApplication()
{
return tap(require $this->laravel->bootstrapPath().'/app.php', function ($app) {
$app->make(ConsoleKernelContract::class)->bootstrap();
});
}

/**
Expand Down
7 changes: 3 additions & 4 deletions src/Illuminate/Routing/RouteCollection.php
Expand Up @@ -131,7 +131,7 @@ public function refreshNameLookups()
/**
* Refresh the action look-up table.
*
* This is done in case any actions are fluently defined or if routes are overwritten.
* This is done in case any actions are overwritten with new controllers.
*
* @return void
*/
Expand All @@ -140,9 +140,8 @@ public function refreshActionLookups()
$this->actionList = [];

foreach ($this->allRoutes as $route) {
$action = $route->getAction();
if (isset($action['controller'])) {
$this->addToActionList($action, $route);
if (isset($route->getAction()['controller'])) {
$this->addToActionList($route->getAction(), $route);
}
}
}
Expand Down

0 comments on commit 5aee967

Please sign in to comment.