1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace LaravelUi5\OData;
6:
7: use LaravelUi5\OData\Service\Contracts\ODataServiceInterface;
8: use LaravelUi5\OData\Service\Contracts\ODataServiceRegistryInterface;
9:
10: /**
11: * Default resolver: ignores the path and returns the single registered ODataService.
12: * Adapters can bind their own ODataServiceRegistryInterface implementation to support
13: * multi-tenant or prefix-based routing strategies.
14: */
15: class ODataServiceRegistry implements ODataServiceRegistryInterface
16: {
17: private ?ODataService $service = null;
18:
19: public function resolve(string $fullPath): ODataServiceInterface
20: {
21: if (!$this->service) {
22: $this->service = new ODataService('', config('odata.namespace', 'com.example.odata'));
23: }
24:
25: return $this->service;
26: }
27:
28: public function services(): array
29: {
30: return [$this->resolve('')];
31: }
32: }
33: