File tree 2 files changed +29
-6
lines changed
2 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -88,13 +88,22 @@ public static function preSystem() {
88
88
89
89
$ routes = Services::routes (true );
90
90
91
- if (self ::$ config ->enableApiRouting && self ::$ database ->tableExists ('api_routes ' )) {
92
- $ routes = Services::routes (true );
93
- /** @var ApiRoute $apiRoutes */
94
- $ apiRoutes = (new ApiRouteModel ())->find ();
95
- foreach ($ apiRoutes as $ route ) {
96
- $ routes ->{$ route ->method }($ route ->from , $ route ->to );
91
+ if (self ::$ config ->enableApiRouting ) {
92
+
93
+ try {
94
+ /** @var ApiRoute $apiRoutes */
95
+ $ apiRoutes = (new ApiRouteModel ())->find ();
96
+
97
+ if ($ apiRoutes ->count ()) {
98
+ $ routes = Services::routes (true );
99
+ foreach ($ apiRoutes as $ route ) {
100
+ $ routes ->{$ route ->method }($ route ->from , $ route ->to );
101
+ }
102
+ }
103
+ } catch (\mysqli_sql_exception $ e ) {
104
+
97
105
}
106
+
98
107
}
99
108
100
109
/*
Original file line number Diff line number Diff line change 7
7
* @package RestExtension\Models
8
8
*/
9
9
class ApiRouteModel extends Model {
10
+
11
+ public $ table = 'api_routes ' ;
12
+ public $ entityName = 'ApiRoute ' ;
13
+ public $ returnType = '\RestExtension\Entities\ApiRoute ' ;
14
+ public $ allowedFields = [
15
+ "id " ,
16
+ "method " ,
17
+ "from " ,
18
+ "to " ,
19
+ "cacheable " ,
20
+ "version " ,
21
+ "scope " ,
22
+ "is_public " ,
23
+ ];
10
24
11
25
public $ hasOne = [
12
26
You can’t perform that action at this time.
0 commit comments