1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LaravelFlare\Flare\Providers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Routing\Router; |
6
|
|
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; |
7
|
|
|
|
8
|
|
|
abstract class RouteServiceProvider extends ServiceProvider |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* This namespace is applied to the controller routes in your routes file. |
12
|
|
|
* |
13
|
|
|
* In addition, it is set as the URL generator's root namespace. |
14
|
|
|
* |
15
|
|
|
* @var string |
16
|
|
|
*/ |
17
|
|
|
protected $namespace = '\LaravelFlare\Flare\Http\Controllers'; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* The compatibility version of this RouteServiceProvider |
21
|
|
|
* |
22
|
|
|
* @var string |
23
|
|
|
*/ |
24
|
|
|
protected $compatibilityVersion; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Define your route model bindings, pattern filters, etc. |
28
|
|
|
* |
29
|
|
|
* @param \Illuminate\Routing\Router $router |
30
|
|
|
*/ |
31
|
|
|
public function boot(Router $router) |
32
|
|
|
{ |
33
|
|
|
parent::boot($router); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Define the routes for the application. |
38
|
|
|
* |
39
|
|
|
* @param \Illuminate\Routing\Router $router |
40
|
|
|
*/ |
41
|
|
|
public function map(Router $router) |
42
|
|
|
{ |
43
|
|
|
$this->registerMiddleware($router); |
44
|
|
|
$this->registerDefinedRoutes($router); |
45
|
|
|
$this->registerDefaultRoutes($router); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Register all the Flare Provided Middleware and Middleware Groups. |
50
|
|
|
* |
51
|
|
|
* We define flarebase rather than extend an existing middleware stack |
52
|
|
|
* since it is possible that a user has amended the default middleware |
53
|
|
|
* of their application in a way that could break Flare. |
54
|
|
|
* |
55
|
|
|
* @param Router $router |
56
|
|
|
*/ |
57
|
|
|
abstract protected function registerMiddleware(Router $router); |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Register the Defined Routes. |
61
|
|
|
* |
62
|
|
|
* This registers all the routes which have been defined by |
63
|
|
|
* Admin sections defined in the Application's Flare Config |
64
|
|
|
* (or in the runtime config if anotehr service provider |
65
|
|
|
* has already started manipulating these dynamically). |
66
|
|
|
* |
67
|
|
|
* @param Router $router |
68
|
|
|
*/ |
69
|
|
|
abstract protected function registerDefinedRoutes(Router $router); |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Register the Default Routes. |
73
|
|
|
* |
74
|
|
|
* This registers all the default routes which are included |
75
|
|
|
* with Flare. These consist of things which will probably |
76
|
|
|
* be included with every application such as the login, |
77
|
|
|
* logout and password reset forms. |
78
|
|
|
* |
79
|
|
|
* The login form can however be hidden by setting the |
80
|
|
|
* 'show' config for 'login' to false. |
81
|
|
|
* |
82
|
|
|
* @param Router $router |
83
|
|
|
*/ |
84
|
|
|
abstract protected function registerDefaultRoutes(Router $router); |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Return the Controller or Controller and Route if provided. |
88
|
|
|
* |
89
|
|
|
* @param string $route |
90
|
|
|
* |
91
|
|
|
* @return string |
92
|
|
|
*/ |
93
|
|
|
protected function adminController($route = null) |
94
|
|
|
{ |
95
|
|
|
if ($route) { |
|
|
|
|
96
|
|
|
return $this->namespace.'\\'.$this->compatibilityVersion.'\AdminController@'.$route; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
return $this->namespace.'\\'.$this->compatibilityVersion.'\AdminController'; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: