1
|
|
|
<?php namespace Arcanedev\RouteViewer\Providers; |
2
|
|
|
|
3
|
|
|
use Arcanedev\Support\Providers\RouteServiceProvider as ServiceProvider; |
4
|
|
|
use Illuminate\Contracts\Routing\Registrar as Router; |
5
|
|
|
use Arcanedev\RouteViewer\Http\Routes; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class RouteServiceProvider |
9
|
|
|
* |
10
|
|
|
* @package Arcanedev\RouteViewer\Providers |
11
|
|
|
* @author ARCANEDEV <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
class RouteServiceProvider extends ServiceProvider |
14
|
|
|
{ |
15
|
|
|
/* ------------------------------------------------------------------------------------------------ |
16
|
|
|
| Getters & Setters |
17
|
|
|
| ------------------------------------------------------------------------------------------------ |
18
|
|
|
*/ |
19
|
|
|
/** |
20
|
|
|
* Get route attributes. |
21
|
|
|
* |
22
|
|
|
* @return array |
23
|
|
|
*/ |
24
|
|
|
public function routeAttributes() |
25
|
|
|
{ |
26
|
|
|
return $this->config('attributes', [ |
27
|
|
|
'prefix' => 'route-viewer', |
28
|
|
|
'namespace' => 'Arcanedev\\RouteViewer\\Http\\Controllers', |
29
|
|
|
]); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Check if routes is enabled. |
34
|
|
|
* |
35
|
|
|
* @return bool |
36
|
|
|
*/ |
37
|
|
|
public function isEnabled() |
38
|
|
|
{ |
39
|
|
|
return $this->config('enabled', false); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Get config value by key |
44
|
|
|
* |
45
|
|
|
* @param string $key |
46
|
|
|
* @param mixed|null $default |
47
|
|
|
* |
48
|
|
|
* @return mixed |
49
|
|
|
*/ |
50
|
|
|
private function config($key, $default = null) |
51
|
|
|
{ |
52
|
|
|
/** @var \Illuminate\Config\Repository $config */ |
53
|
|
|
$config = $this->app['config']; |
54
|
|
|
|
55
|
|
|
return $config->get("route-viewer.route.{$key}", $default); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/* ------------------------------------------------------------------------------------------------ |
59
|
|
|
| Main Functions |
60
|
|
|
| ------------------------------------------------------------------------------------------------ |
61
|
|
|
*/ |
62
|
|
|
/** |
63
|
|
|
* Define the routes for the application. |
64
|
|
|
* |
65
|
|
|
* @param \Illuminate\Contracts\Routing\Registrar $router |
66
|
|
|
*/ |
67
|
|
|
public function map(Router $router) |
68
|
|
|
{ |
69
|
|
|
if ($this->isEnabled()) { |
70
|
|
|
$router->group($this->routeAttributes(), function(Router $router) { |
71
|
|
|
Routes\RouteViewerRoutes::register($router); |
72
|
|
|
}); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|