Service provider refactoring

This commit is contained in:
Graham Campbell
2015-01-01 14:30:54 +00:00
parent b90573a097
commit c064ece5f5
3 changed files with 4 additions and 6 deletions

View File

@@ -0,0 +1,40 @@
<?php
namespace CachetHQ\Cachet\Providers;
use Illuminate\Support\ServiceProvider;
use RecursiveDirectoryIterator;
class RoutingServiceProvider extends ServiceProvider
{
public function register()
{
//
}
public function boot()
{
$this->routesInDirectory();
}
/**
* Organise Routes.
*
* @param string $app
*/
private function routesInDirectory($app = '')
{
$routeDir = app_path('routes/'.$app.($app !== '' ? '/' : null));
$iterator = new RecursiveDirectoryIterator($routeDir);
$iterator->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
foreach ($iterator as $route) {
$isDotFile = strpos($route->getFilename(), '.') === 0;
if (!$isDotFile && !$route->isDir()) {
require $routeDir.$route->getFilename();
}
}
}
}