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_api to 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 locales key. 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_api is no longer normalized by this module.

Remaining tasks

Everything.

Issue fork myrest-3618471

Command icon 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

sergeydruua created an issue. See original summary.

  • sergeydruua committed 8dee60b2 on 1.0.x
    Issue #3618471: Let a resource declare the locales key and drop the...
sergeydruua’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

sergeydruua’s picture

Status: Fixed » Closed (fixed)