Method to enable a resource type field disabled by a previous ResourceTypeBuildEvent subscriber

Created on 3 February 2020, over 4 years ago
Updated 16 February 2024, 4 months ago

If a ResourceTypeBuildEvent disables a field, for example:

      // Disable the internal Drupal identifiers.
      if (strpos($field->getPublicName(), 'drupal_internal__') === 0) {
        $event->disableField($field);
      }

A lower priority subscriber cannot undo that change. There is no "undisableField"

Solution

Added ResourceTypeBuildEvent::enableField which enables a field.

Todo

  1. Add a change record for this change.
✨ Feature request
Status

Needs work

Version

11.0 πŸ”₯

Component
JSON APIΒ  β†’

Last updated 1 day ago

Created by

πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

Live updates comments and jobs are added and updated live.
  • API addition

    Enhances an existing API or introduces a new subsystem. Depending on the size and impact, possibly backportable to earlier major versions.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request β†’ as a guide.

    Verified the test coverage running locally without the fix. I got

    Error : Call to undefined method Drupal\jsonapi\ResourceType\ResourceTypeBuildEvent::enableField()

    Which is good!

    All threads are resolved on the MR
    All tests are green
    Change record is added and make sense (to me at least)
    New functions are typehinted

    This looks good to me.

  • Status changed to Needs review about 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    There are several other options here. You could alter the service that subscribes the event or you could implement an event subscriber with a higher priority and stop propagation. I'm not sure that adding enableField() to fight it out with disableField() is going to improve the situation. I can imagine people adding an event to disable a field, that was disabled and then enabled. Feels odd.

  • Status changed to Needs work about 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Alright issue should be reworked based on #22 or explained why this is the better approach.

    Decision should be documented in issue summary please

    Thanks.

  • πŸ‡ΊπŸ‡ΈUnited States matthand Riverdale Park, Maryland

    Is there a way to re-enable the UUID field that is disabled on node resources by JSON:API without this new enableField method? I don't think so. Real world scenario of trying to match a legacy Drupal 8 JSON:API endpoint to prevent consumer apps requiring a rebuild.

Production build 0.69.0 2024