You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: simplify ServiceProvider and externalize multi-endpoint support
- remove "extra.laravel" from composer.json to disable auto-registration
- always boot default Endpoint in ServiceProvider for consistent behavior
- drop request path inspection logic for segmented endpoint resolution
==> apps requiring multiple OData endpoints should now implement and register
their own ServiceProvider (see docs for example)
Copy file name to clipboardExpand all lines: doc/getting-started/endpoint.md
+129Lines changed: 129 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,135 @@ By default, `flat3/lodata` exposes a **single global service endpoint**. However
9
9
10
10
This is where **service endpoints** come in. They allow you to split your schema into smaller, focused units, each with its own `$metadata` document and queryable surface.
11
11
12
+
## Replacing the ServiceProvider
13
+
14
+
To enable multiple service endpoints you need to replace `\Flat3\Lodata\ServiceProvider` with your own implementation that inspects the request path and boots the appropriate endpoint based on your configuration.
15
+
16
+
Take this sample implementation:
17
+
18
+
```php
19
+
<?php
20
+
21
+
namespace App\Providers;
22
+
23
+
use Composer\InstalledVersions;
24
+
use Flat3\Lodata\Controller\Monitor;
25
+
use Flat3\Lodata\Controller\OData;
26
+
use Flat3\Lodata\Controller\ODCFF;
27
+
use Flat3\Lodata\Controller\PBIDS;
28
+
use Flat3\Lodata\Controller\Response;
29
+
use Flat3\Lodata\Helper\Filesystem;
30
+
use Flat3\Lodata\Helper\Flysystem;
31
+
use Flat3\Lodata\Helper\DBAL;
32
+
use Flat3\Lodata\Helper\Symfony;
33
+
use Flat3\Lodata\Interfaces\ServiceEndpointInterface;
if (0 === sizeof($serviceUris) || count($segments) === 1) {
61
+
$service = new Endpoint('');
62
+
}
63
+
else if (array_key_exists($segments[1], $serviceUris)) {
64
+
$clazz = $serviceUris[$segments[1]];
65
+
if (!class_exists($clazz)) {
66
+
throw new RuntimeException(sprintf('Endpoint class `%s` does not exist', $clazz));
67
+
}
68
+
if (!is_subclass_of($clazz, ServiceEndpointInterface::class)) {
69
+
throw new RuntimeException(sprintf('Endpoint class `%s` must implement Flat3\\Lodata\\Interfaces\\ServiceEndpointInterface', $clazz));
70
+
}
71
+
$service = new $clazz($segments[1]);
72
+
}
73
+
else {
74
+
$service = new Endpoint('');
75
+
}
76
+
77
+
$this->bootServices($service);
78
+
}
79
+
}
80
+
}
81
+
82
+
private function bootServices(Endpoint $service): void
83
+
{
84
+
$this->app->instance(Endpoint::class, $service);
85
+
86
+
$this->app->bind(DBAL::class, function (Application $app, array $args) {
87
+
return version_compare(InstalledVersions::getVersion('doctrine/dbal'), '4.0.0', '>=') ? new DBAL\DBAL4($args['connection']) : new DBAL\DBAL3($args['connection']);
0 commit comments