By wim leers on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.5.x
Introduced in version:
8.5.0
Issue links:
Description:
REST resources no longer have one route per supported format for the GET method.
For example here are the routes for the Node entity resource:
- Drupal <8.4.0 (8.0.x, 8.1.x, 8.2.x, 8.3.x)
-
rest.entity.node.GET.hal_jsonrest.entity.node.GET.jsonrest.entity.node.GET.…
- Drupal >=8.5.0
rest.entity.node.GET
So you can now generate the URL to access node 5 in json format using:
$url = Url::fromRoute('rest.entity.node.GET')
->setRouteParameter('node', 5)
->setRouteParameter('_format', 'json');
Backwards compatibility for clients (HTTP API): ✔️
Since the previous per-format routes all had the same system path this change should not affect any clients using the REST resources.
Backwards compatibility for Drupal code: ✔️
Not even Drupal code that relies on the (now deprecated) route names needs to be updated — this continues to work just fine:
// Deprecated, but still works until Drupal 9!
$url = Url::fromRoute('rest.entity.node.GET.json')
->setRouteParameter('node', 5);
(Backwards compatibility is provided through an outbound route processor.)
Impacts:
Module developers