Skip to content

Commit

Permalink
Fixing the addRouteFromFile in RouteServiceProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanedev-maroc committed Sep 9, 2015
1 parent c890b20 commit e603730
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/Laravel/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,23 @@ private function checkRouteNamespace()
* Add route from file.
*
* @param SplFileInfo $file
* @param string $needle
*/
private function addRouteFromFile(SplFileInfo $file, $needle = 'Routes\\')
private function addRouteFromFile(SplFileInfo $file)
{
if ($file->isFile() && pathinfo($file, PATHINFO_EXTENSION) === 'php') {
$pos = strpos($file->getRealPath(), $needle);

if ($pos !== false) {
$route = substr(
str_replace('.php', '', $file->getRealPath()),
$pos + strlen($needle)
);
$this->addRoute($route);
}
if (
! $file->isFile() ||
pathinfo($file, PATHINFO_EXTENSION) !== 'php'
) return;

$routeFolder = 'Routes' . DS;
$pos = strpos($file->getRealPath(), $routeFolder);

if ($pos !== false) {
$route = substr(
str_replace('.php', '', $file->getRealPath()),
$pos + strlen($routeFolder)
);
$this->addRoute($route);
}
}

Expand Down

0 comments on commit e603730

Please sign in to comment.