Problem/Motivation
MyrestNormalizer::supportsNormalization() answers TRUE for routes carrying _myrest_api — correct — or _cart_api, which is a route requirement of a cart module belonging to one site and unknown to this one. Further in, the locales key is suppressed by an exclusion list of six literal plugin IDs: sitemap_get_resource, robots_txt_get_resource, search_autocomplete_get_resource, search_results_get_resource, review_add_resource, review_add_get_data_resource. Four of those belong to satellite modules — mysitemap and mysearch — that may or may not be installed. A published module cannot carry the plugin IDs of its consumers, and a satellite cannot get the behaviour it needs without patching this module.
The registration scope itself is already correct and is not what this issue changes: the normalizer does not answer for arbitrary REST responses.
Proposed resolution
- Replace the exclusion list with a plugin annotation property —
myrest_locales, default TRUE — so that a resource declares its own behaviour and a satellite carries the declaration in its own code. - Remove
_cart_api. A site that wants its own routes normalized by this module adds_myrest_apito them, which is the documented way and works without this module knowing the site exists. - Record both as part of the module's public API, since the modules that extend this one depend on them.
- Note for the rollout: the four satellite resources need the property added on their side before this lands, or their responses gain a
localeskey. That is coordinated with those sites when they migrate, and the change is additive rather than breaking. - Coverage: a resource declaring the property FALSE has no
locales, one declaring nothing has it, and a route with only_cart_apiis no longer normalized by this module.
Remaining tasks
Everything.
Issue fork myrest-3618471
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
sergeydruua commentedComment #6
sergeydruua commented