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
Having the REST controllers set as services enables using features such as
54
+
The [`controller.service_arguments` tag]([[= symfony_doc =]]/controller/service.html#using-the-controller-service-arguments-service-tag) declares the controller as a service receiving injections.
55
+
It helps the autowiring of the serializer in the constructor.
55
56
56
-
- TODO: `controller.service_arguments`??
57
-
- TODO: `ibexa.api_platform.resource`tag is needed to have the route available in live doc (/api/ibexa/v2/doc#/App/api_greet_get)
57
+
The `ibexa.api_platform.resource` tag declares the service as an API Platform resource.
58
58
59
59
### Controller action
60
60
61
61
A REST controller should:
62
62
63
-
- return an object (passed automatically to a normaliser) or a `Response` (to customize it further)
64
-
- TODO: extend `Ibexa\Rest\Server\Controller` to inherit utils methods and properties like `InputDispatcher` or `RequestParser`
63
+
- return an object (passed automatically to a normalizer) or a `Response` (to customize it further)
64
+
- extend `Ibexa\Rest\Server\Controller` to inherit useful methods and properties like `InputDispatcher` or `RequestParser`
If the returned value was depending on a location, it could have been wrapped in a `CachedValue` to be cached by the reverse proxy (like Varnish) for future calls.
75
-
76
-
`CachedValue` is used in the following way:
77
-
78
-
```php
79
-
return new CachedValue(
80
-
new MyValue($args…),
81
-
['locationId'=> $locationId]
82
-
);
83
-
```
84
-
72
+
<summary>HTTP Cache</summary>
73
+
74
+
If the returned value was depending on a location, it could have been wrapped in a <code>CachedValue</code>
75
+
to be cached by the reverse proxy (like Varnish or Fastly) for future calls.
You can add the new resource to the [root resource](rest_api_usage.md#rest-root) through a configuration with the following pattern:
179
177
180
178
```yaml
@@ -192,7 +190,7 @@ The parameter values can be a real value or a placeholder.
192
190
For example, `'router.generate("ibexa.rest.load_location", {locationPath: "1/2"})'` results in `/api/ibexa/v2/content/locations/1/2` while `'router.generate("ibexa.rest.load_location", {locationPath: "{locationPath}"})'` gives `/api/ibexa/v2/content/locations/{locationPath}`.
193
191
This syntax is based on Symfony's [expression language]([[= symfony_doc =]]/components/expression_language/index.html), an extensible component that allows limited/readable scripting to be used outside the code context.
194
192
195
-
In this example, `app.rest.greeting` is available in every SiteAccess (`default`):
193
+
In the following example, `app.rest.greeting` is available in every SiteAccess (`default`):
196
194
197
195
```yaml
198
196
ibexa_rest:
@@ -204,12 +202,12 @@ ibexa_rest:
204
202
href: 'router.generate("app.rest.greeting")'
205
203
```
206
204
207
-
You can place this configuration in any regular config file, like the existing `config/packages/ibexa.yaml`, or a new `config/packages/ibexa_rest.yaml` file.
205
+
You can place this configuration in any regular config file,
206
+
like the existing `config/packages/ibexa.yaml`,
207
+
or a new `config/packages/ibexa_rest.yaml` file.
208
208
209
-
The above example adds the following entry to the root XML output:
209
+
This example adds the following entry to the root XML output:
0 commit comments