|
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 the routes for the application. |
|
28
|
|
|
* |
|
29
|
|
|
* @param \Illuminate\Routing\Router $router |
|
30
|
|
|
*/ |
|
31
|
|
|
public function map(Router $router) |
|
32
|
|
|
{ |
|
33
|
|
|
$this->registerMiddleware($router); |
|
34
|
|
|
$this->registerDefinedRoutes($router); |
|
35
|
|
|
$this->registerDefaultRoutes($router); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Register all the Flare Provided Middleware and Middleware Groups. |
|
40
|
|
|
* |
|
41
|
|
|
* We define flarebase rather than extend an existing middleware stack |
|
42
|
|
|
* since it is possible that a user has amended the default middleware |
|
43
|
|
|
* of their application in a way that could break Flare. |
|
44
|
|
|
* |
|
45
|
|
|
* @param Router $router |
|
46
|
|
|
*/ |
|
47
|
|
|
abstract protected function registerMiddleware(Router $router); |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Register the Defined Routes. |
|
51
|
|
|
* |
|
52
|
|
|
* This registers all the routes which have been defined by |
|
53
|
|
|
* Admin sections defined in the Application's Flare Config |
|
54
|
|
|
* (or in the runtime config if anotehr service provider |
|
55
|
|
|
* has already started manipulating these dynamically). |
|
56
|
|
|
* |
|
57
|
|
|
* @param Router $router |
|
58
|
|
|
*/ |
|
59
|
|
|
abstract protected function registerDefinedRoutes(Router $router); |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Register the Default Routes. |
|
63
|
|
|
* |
|
64
|
|
|
* This registers all the default routes which are included |
|
65
|
|
|
* with Flare. These consist of things which will probably |
|
66
|
|
|
* be included with every application such as the login, |
|
67
|
|
|
* logout and password reset forms. |
|
68
|
|
|
* |
|
69
|
|
|
* The login form can however be hidden by setting the |
|
70
|
|
|
* 'show' config for 'login' to false. |
|
71
|
|
|
* |
|
72
|
|
|
* @param Router $router |
|
73
|
|
|
*/ |
|
74
|
|
|
abstract protected function registerDefaultRoutes(Router $router); |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Return the Controller or Controller and Route if provided. |
|
78
|
|
|
* |
|
79
|
|
|
* @param string $route |
|
80
|
|
|
* |
|
81
|
|
|
* @return string |
|
82
|
|
|
*/ |
|
83
|
|
|
protected function adminController($route = null) |
|
84
|
|
|
{ |
|
85
|
|
|
if ($route) { |
|
|
|
|
|
|
86
|
|
|
return $this->namespace.'\\'.$this->compatibilityVersion.'\AdminController@'.$route; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
return $this->namespace.'\\'.$this->compatibilityVersion.'\AdminController'; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: