14
14
use Flat3 \Lodata \Helper \Flysystem ;
15
15
use Flat3 \Lodata \Helper \DBAL ;
16
16
use Flat3 \Lodata \Helper \Symfony ;
17
- use Illuminate \Database \ConnectionInterface ;
18
17
use Illuminate \Foundation \Application ;
19
18
use Illuminate \Support \Facades \Route ;
20
19
use Symfony \Component \HttpKernel \Kernel ;
@@ -51,13 +50,12 @@ public function boot()
51
50
$ segments = explode ('/ ' , request ()->path ());
52
51
53
52
// we only kick off operation when path prefix is configured in lodata.php
54
- // as all requests share the same root configuration
53
+ // and bypass all other routes for performance
55
54
if ($ segments [0 ] === config ('lodata.prefix ' )) {
56
55
57
56
// next look up the configured service endpoints
58
57
$ serviceUris = config ('lodata.endpoints ' , []);
59
58
60
- $ service = null ;
61
59
if (0 === sizeof ($ serviceUris )) {
62
60
// when no locators are defined, fallback to global mode; this will
63
61
// ensure compatibility with prior versions of this package
@@ -68,10 +66,9 @@ public function boot()
68
66
$ service = new $ clazz ($ segments [1 ]);
69
67
}
70
68
else {
71
- // when no service definition is configured for the path segment,
72
- // we abort with an error condition; typically a dev working on
73
- // setting up his project
74
- abort ('No odata service endpoint defined for path ' . $ segments [1 ]);
69
+ // when no service definition could be found for the path segment,
70
+ // we assume global scope
71
+ $ service = new Endpoint ('' );
75
72
}
76
73
77
74
$ this ->bootServices ($ service );
@@ -87,6 +84,10 @@ private function bootServices($service): void
87
84
// app()->make(ODataService::class)->endpoint()
88
85
$ this ->app ->instance (Endpoint::class, $ service );
89
86
87
+ $ this ->app ->bind (DBAL ::class, function (Application $ app , array $ args ) {
88
+ return version_compare (InstalledVersions::getVersion ('doctrine/dbal ' ), '4.0.0 ' , '>= ' ) ? new DBAL \DBAL4 ($ args ['connection ' ]) : new DBAL \DBAL3 ($ args ['connection ' ]);
89
+ });
90
+
90
91
$ this ->loadJsonTranslationsFrom (__DIR__ .'/../lang ' );
91
92
92
93
// next instantiate and discover the global Model
@@ -109,10 +110,6 @@ private function bootServices($service): void
109
110
return class_exists ('League\Flysystem\Adapter\Local ' ) ? new Flysystem \Flysystem1 () : new Flysystem \Flysystem3 ();
110
111
});
111
112
112
- $ this ->app ->bind (DBAL ::class, function (Application $ app , array $ args ) {
113
- return version_compare (InstalledVersions::getVersion ('doctrine/dbal ' ), '4.0.0 ' , '>= ' ) ? new DBAL \DBAL4 ($ args ['connection ' ]) : new DBAL \DBAL3 ($ args ['connection ' ]);
114
- });
115
-
116
113
$ route = $ service ->route ();
117
114
$ middleware = config ('lodata.middleware ' , []);
118
115
0 commit comments