|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace AbterPhp\Admin\Config; |
|
6
|
|
|
|
|
7
|
|
|
use AbterPhp\Admin\Constant\Path; |
|
|
|
|
|
|
8
|
|
|
use AbterPhp\Framework\Exception\Config as ConfigException; |
|
9
|
|
|
use Opulence\Environments\Environment; |
|
10
|
|
|
|
|
11
|
|
|
class Routes |
|
12
|
|
|
{ |
|
13
|
|
|
public const DASHBOARD_PATH = '/dashboard'; |
|
14
|
|
|
public const PROFILE_PATH = '/profile'; |
|
15
|
|
|
|
|
16
|
|
|
private const ADMIN_LOGIN_PATH = 'ADMIN_LOGIN_PATH'; |
|
17
|
|
|
private const ADMIN_LOGOUT_PATH = 'ADMIN_LOGOUT_PATH'; |
|
18
|
|
|
private const ADMIN_BASE_PATH = 'ADMIN_BASE_PATH'; |
|
19
|
|
|
private const API_BASE_PATH = 'API_BASE_PATH'; |
|
20
|
|
|
|
|
21
|
|
|
/** @var string|null */ |
|
22
|
|
|
protected static $loginPath; |
|
23
|
|
|
|
|
24
|
|
|
/** @var string|null */ |
|
25
|
|
|
protected static $logoutPath; |
|
26
|
|
|
|
|
27
|
|
|
/** @var string|null */ |
|
28
|
|
|
protected static $adminBasePath; |
|
29
|
|
|
|
|
30
|
|
|
/** @var string|null */ |
|
31
|
|
|
protected static $apiBasePath; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param string $loginPath |
|
35
|
|
|
*/ |
|
36
|
|
|
public static function setLoginPath(string $loginPath): void |
|
37
|
|
|
{ |
|
38
|
|
|
static::$loginPath = $loginPath; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @return string |
|
43
|
|
|
*/ |
|
44
|
|
|
public static function getLoginPath(): string |
|
45
|
|
|
{ |
|
46
|
|
|
if (null !== static::$loginPath) { |
|
47
|
|
|
return static::$loginPath; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
$loginPath = Environment::getVar(static::ADMIN_LOGIN_PATH); |
|
51
|
|
|
if (null === $loginPath) { |
|
52
|
|
|
throw new ConfigException(__CLASS__, [static::ADMIN_LOGIN_PATH]); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
static::$loginPath = (string)$loginPath; |
|
56
|
|
|
|
|
57
|
|
|
return static::$loginPath; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param string $logoutPath |
|
62
|
|
|
*/ |
|
63
|
|
|
public static function setLogoutPath(string $logoutPath): void |
|
64
|
|
|
{ |
|
65
|
|
|
static::$logoutPath = $logoutPath; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @return string |
|
70
|
|
|
*/ |
|
71
|
|
|
public static function getLogoutPath(): string |
|
72
|
|
|
{ |
|
73
|
|
|
if (null !== static::$logoutPath) { |
|
74
|
|
|
return static::$logoutPath; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
$logoutPath = Environment::getVar(static::ADMIN_LOGOUT_PATH); |
|
78
|
|
|
if (null === $logoutPath) { |
|
79
|
|
|
throw new ConfigException(__CLASS__, [static::ADMIN_LOGOUT_PATH]); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
static::$logoutPath = (string)$logoutPath; |
|
83
|
|
|
|
|
84
|
|
|
return static::$logoutPath; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @param string $adminBasePath |
|
89
|
|
|
*/ |
|
90
|
|
|
public static function setAdminBasePath(string $adminBasePath): void |
|
91
|
|
|
{ |
|
92
|
|
|
static::$adminBasePath = $adminBasePath; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @return string |
|
97
|
|
|
*/ |
|
98
|
|
|
public static function getAdminBasePath(): string |
|
99
|
|
|
{ |
|
100
|
|
|
if (null !== static::$adminBasePath) { |
|
101
|
|
|
return static::$adminBasePath; |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
$adminBasePath = Environment::getVar(static::ADMIN_BASE_PATH); |
|
105
|
|
|
if (null === $adminBasePath) { |
|
106
|
|
|
throw new ConfigException(__CLASS__, [static::ADMIN_BASE_PATH]); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
static::$adminBasePath = (string)$adminBasePath; |
|
110
|
|
|
|
|
111
|
|
|
return static::$adminBasePath; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @param string $apiBasePath |
|
116
|
|
|
*/ |
|
117
|
|
|
public static function setApiBasePath(string $apiBasePath): void |
|
118
|
|
|
{ |
|
119
|
|
|
static::$apiBasePath = $apiBasePath; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @return string |
|
124
|
|
|
*/ |
|
125
|
|
|
public static function getApiBasePath(): string |
|
126
|
|
|
{ |
|
127
|
|
|
if (null !== static::$apiBasePath) { |
|
128
|
|
|
return static::$apiBasePath; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
$apiBasePath = Environment::getVar(static::API_BASE_PATH); |
|
132
|
|
|
if (null === $apiBasePath) { |
|
133
|
|
|
throw new ConfigException(__CLASS__, [static::API_BASE_PATH]); |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
static::$apiBasePath = (string)$apiBasePath; |
|
137
|
|
|
|
|
138
|
|
|
return static::$apiBasePath; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @return string |
|
143
|
|
|
*/ |
|
144
|
|
|
public static function getLoginFailurePath(): string |
|
145
|
|
|
{ |
|
146
|
|
|
return static::getLoginPath(); |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* @return string |
|
151
|
|
|
*/ |
|
152
|
|
|
public static function getLoginSuccessPath(): string |
|
153
|
|
|
{ |
|
154
|
|
|
return static::getAdminBasePath() . static::DASHBOARD_PATH; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* @return string |
|
159
|
|
|
*/ |
|
160
|
|
|
public static function getProfilePath(): string |
|
161
|
|
|
{ |
|
162
|
|
|
return static::getAdminBasePath() . static::PROFILE_PATH; |
|
163
|
|
|
} |
|
164
|
|
|
} |
|
165
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths