|
5 | 5 | use Flat3\Lodata\Model;
|
6 | 6 |
|
7 | 7 | /**
|
8 |
| - * Interface for defining a custom OData service endpoint. |
| 8 | + * Interface for defining a modular OData service endpoint in Laravel. |
9 | 9 | *
|
10 |
| - * Implementers can use this interface to expose a specific service under a custom path, |
11 |
| - * define its namespace, route behavior, and optionally provide a statically generated |
12 |
| - * $metadata document. |
| 10 | + * Implementers of this interface represent individually addressable OData services. |
| 11 | + * Each mounted under its own URI segment and backed by a schema model. |
| 12 | + * |
| 13 | + * This enables clean separation of business domains and supports multi-endpoint |
| 14 | + * discovery for modular application design. |
| 15 | + * |
| 16 | + * Configuration versus Declaration |
| 17 | + * -------------------------------- |
| 18 | + * The public URI segment used to expose a service is NOT determined by the |
| 19 | + * implementing class itself, but by the service map in `config/lodata.php`: |
| 20 | + * |
| 21 | + * ```php |
| 22 | + * 'endpoints' => [ |
| 23 | + * 'users' => \App\OData\UsersEndpoint::class, |
| 24 | + * 'budgets' => \App\OData\BudgetsEndpoint::class, |
| 25 | + * ] |
| 26 | + * ``` |
| 27 | + * |
| 28 | + * This keeps the routing surface under application control, and avoids |
| 29 | + * conflicts when two modules declare the same internal segment. |
| 30 | + * |
| 31 | + * To implement an endpoint: |
| 32 | + * - Extend `Flat3\Lodata\Endpoint` or implement this interface directly |
| 33 | + * - Register the class in `config/lodata.php` under a unique segment key |
| 34 | + * - Define the `discover()` method to expose entities via OData |
13 | 35 | */
|
14 | 36 | interface ServiceEndpointInterface
|
15 | 37 | {
|
| 38 | + /** |
| 39 | + * Returns the ServiceURI segment name for this OData endpoint. |
| 40 | + * |
| 41 | + * This value is used in routing and metadata resolution. It Must be globally unique. |
| 42 | + * |
| 43 | + * @return string The segment (path identifier) of the endpoint |
| 44 | + */ |
| 45 | + public function serviceUri(): string; |
16 | 46 |
|
17 | 47 | /**
|
18 |
| - * Returns the relative endpoint identifier within the OData service URI space. |
| 48 | + * Returns the fully qualified URL for this OData endpoint. |
19 | 49 | *
|
20 |
| - * This is the part that appears between the configured Lodata prefix and |
21 |
| - * the `$metadata` segment, e.g.: |
22 |
| - * https://<server>:<port>/<config('lodata.prefix')>/<endpoint>/$metadata |
| 50 | + * This includes the application host, port, and the configured segment, |
| 51 | + * https://<server>:<port>/<config('lodata.prefix')>/<service-uri>/, |
| 52 | + * Example: https://example.com/odata/users/ |
23 | 53 | *
|
24 |
| - * @return string The relative OData endpoint path |
| 54 | + * This URL forms the base of the OData service space, and is used for navigation links |
| 55 | + * and metadata discovery. |
| 56 | + * |
| 57 | + * @return string The full URL of the service endpoint |
25 | 58 | */
|
26 | 59 | public function endpoint(): string;
|
27 | 60 |
|
28 | 61 | /**
|
29 |
| - * Returns the full request route to this service endpoint. |
| 62 | + * Returns the internal Laravel route path for this OData service endpoint. |
| 63 | + * |
| 64 | + * This is the relative URI path that Laravel uses to match incoming requests, |
| 65 | + * typically composed of the configured Lodata prefix and the service segment. |
30 | 66 | *
|
31 |
| - * This typically resolves to the route path used by Laravel to handle |
32 |
| - * incoming requests for this specific service instance. |
| 67 | + * Example: "odata/users" |
33 | 68 | *
|
34 |
| - * @return string The full HTTP route to the endpoint |
| 69 | + * @return string Relative route path for the endpoint |
35 | 70 | */
|
36 | 71 | public function route(): string;
|
37 | 72 |
|
|
0 commit comments