mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 21:49:01 +01:00
Moved routesInDirectory() function to service provider
This commit is contained in:
parent
66b9b881c8
commit
15b43dc9a9
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Support\ServiceProviders;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -123,9 +123,11 @@ return array(
|
||||
'Illuminate\Workbench\WorkbenchServiceProvider',
|
||||
|
||||
'Dingo\Api\Provider\ApiServiceProvider',
|
||||
'Thujohn\Rss\RssServiceProvider',
|
||||
|
||||
'CachetHQ\Cachet\Support\ServiceProviders\RepositoryServiceProvider',
|
||||
'Thujohn\Rss\RssServiceProvider',
|
||||
'CachetHQ\Cachet\Support\ServiceProviders\RoutingServiceProvider',
|
||||
|
||||
),
|
||||
|
||||
/*
|
||||
|
@ -6,19 +6,3 @@ Route::model('incident_template', 'IncidentTemplate');
|
||||
Route::model('setting', 'Setting');
|
||||
Route::model('webhook', 'WebHook');
|
||||
Route::model('user', 'User');
|
||||
|
||||
routesInDirectory();
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user