1
+ <?php
2
+
3
+ namespace Flat3 \Lodata \Interfaces ;
4
+
5
+ use Flat3 \Lodata \Model ;
6
+
7
+ /**
8
+ * Interface for defining a custom OData service endpoint.
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.
13
+ */
14
+ interface ServiceEndpointInterface
15
+ {
16
+
17
+ /**
18
+ * Returns the relative endpoint identifier within the OData service URI space.
19
+ *
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
23
+ *
24
+ * @return string The relative OData endpoint path
25
+ */
26
+ public function endpoint (): string ;
27
+
28
+ /**
29
+ * Returns the full request route to this service endpoint.
30
+ *
31
+ * This typically resolves to the route path used by Laravel to handle
32
+ * incoming requests for this specific service instance.
33
+ *
34
+ * @return string The full HTTP route to the endpoint
35
+ */
36
+ public function route (): string ;
37
+
38
+ /**
39
+ * Returns the XML namespace used in the `$metadata` document.
40
+ *
41
+ * This value is injected as the `Namespace` attribute of the <Schema> element
42
+ * in the OData CSDL document, and must be globally unique per service.
43
+ *
44
+ * @see https://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/odata-csdl-xml-v4.01.html#sec_Schema
45
+ *
46
+ * @return string The schema namespace for the service
47
+ */
48
+ public function namespace (): string ;
49
+
50
+ /**
51
+ * Returns the absolute filesystem path to a statically annotated `$metadata` file.
52
+ *
53
+ * This method can be overridden to provide a custom pre-generated CSDL XML file
54
+ * for the OData metadata endpoint. If a path is returned, it will be used as-is
55
+ * instead of dynamically generating the schema from model definitions.
56
+ * Return `null` to fall back to automatic schema generation.
57
+ *
58
+ * @return string|null Full path to a static $metadata XML file, or null for dynamic generation
59
+ */
60
+ public function cachedMetadataXMLPath (): ?string ;
61
+
62
+ /**
63
+ * Builds or enriches the model used for schema generation and metadata discovery.
64
+ *
65
+ * This method should populate the provided `Model` instance with entity sets,
66
+ * types, annotations, and operations that define the service schema. It is
67
+ * invoked during the metadata bootstrapping process when an OData service request
68
+ * is processed.
69
+ *
70
+ * @param Model $model The schema model to populate
71
+ * @return Model The enriched model instance representing the OData service
72
+ */
73
+ public function discover (Model $ model ): Model ;
74
+ }
0 commit comments