Problem/Motivation
This is awkward.
#2758897: Move rest module's "link manager" services to serialization module landed on January 31. It moved the "link manager" services from the REST module to the Serialization module. This was the reasoning, written on June 30, 2016, by @larowlan:
At present serialization of entities with their references requires the link managers in rest module.
This means modules like hal and default_content rely on having rest module enabled, when all they really want to do is deserialize/denormalize entities with references intact.
We shouldn't need rest module enabled to be able to normalize/denormalize to and from hal_json or any other format that supports entity reference relations.
This is entirely sensible. Of course the HAL and default_content modules shouldn't have to rely on the rest module to be able to (de)serialize entities!
This also unblocked #2829746: Clean up \Drupal\jsonapi\LinkManager\LinkManager(Interface): the JSON API contrib module has its own types of links to add. And we were looking forward to let it add new kinds of links using the link manager. Because that's what a link manager is designed for, right? To manage links, to allow new kinds of links depending on the format, etc. And since the link manager used to live in the REST module, it was already generic. It just happens to be a serialization (hence Serialization module) task, not a routing/configuration (hence REST module) task. So we just moved it.
But, as I started to refactor the JSON API link manager to extend the REST/Serialization module link manager, I ran into some unpleasant surprises. See #2829746-12: Clean up \Drupal\jsonapi\LinkManager\LinkManager(Interface). Turns out the REST/Serialization module link manager is… not remotely generic! It's:
- 100% tied to the HAL module's needs
- absolutely not extensible: adding new kinds of links requires us to break the
LinkManagerInterface
, hence breaking existing implementations
Conclusion: this is not a generic link manager, this is a HAL link manager! We all assumed that it was, but it was not. Again, for the full painful detail, see #2829746-12: Clean up \Drupal\jsonapi\LinkManager\LinkManager(Interface).
Marked this critical because it should happen before the release of Drupal 8.3.0, otherwise we're stuck with the link manager in the Serialization module. If the Serialization module ever gets a link manager, it ought to be generic.
Proposed resolution
Undo the move of the REST module's link manager to the Serialization module, move it to the HAL module instead.
(With exactly the same BC precautions. The only difference is that there's now again 0 mentions of "link manager" in the Serialization module; all of those have been moved to the HAL module.)
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.