Problem/Motivation
#2843753: Prevent ContentModerationState from being exposed by REST's EntityResource ensured that the ContentModerationState
entity type would never be exposed by the REST module, by implementing hook_rest_resource_alter()
to remove the automatically derived REST resource plugin for this entity type. This was effectively a hack, a work-around, because the proper infrastructure was missing.
#2936714: Entity type definitions cannot be set as 'internal' just introduced that proper infrastructure: the ability to mark entity types as "internal" (which already was introduced for fields and properties several months ago).
Thanks to that new infrastructure, the REST module can now start to respect that: internal entity types should never be exposed via HTTP APIs such as the rest
module's. Similarly, contributed modules providing HTTP APIs such as https://www.drupal.org/project/jsonapi (#2932035: ResourceTypes should be internal when EntityType::isInternal is TRUE) and https://www.drupal.org/project/graphql can also start to support this.
Proposed resolution
- Update
\Drupal\rest\Plugin\Deriver\EntityDeriver
to respectEntityTypeInterface::isInternal()
- Set
internal = TRUE
on\Drupal\content_moderation\Entity\ContentModerationState
to use this - Remove
content_moderation_rest_resource_alter()
, because it's no longer necessary - The existing test coverage in
\Drupal\Tests\content_moderation\Kernel\ContentModerationStateResourceTest
proves that this still works as expected for the one entity type in Drupal core that is "internal" - Finally, update the automated "entity REST test coverage" test, that ensures that every entity type has REST test coverage, to only require REST test coverage for non-internal entity types
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2941622-2.patch | 5.06 KB | Wim Leers |
Comments
Comment #2
Wim LeersComment #3
Wim LeersThe sister issue for https://www.drupal.org/project/jsonapi is #2932035: ResourceTypes should be internal when EntityType::isInternal is TRUE.
Comment #4
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedThe Workspace module is following closely :) #2941625: Mark the workspace_association entity type as internal
Comment #5
Wim Leers@amateescu++
Comment #6
timmillwoodWell this makes things a bit more easier!
LGTM!
Comment #7
Wim LeersYay!
(And fix typo in IS.)
Comment #9
timmillwoodUnrelated test fail
Comment #10
alexpottCommitted and pushed 5a9de4fc76 to 8.6.x and 054722c94c to 8.5.x. Thanks!
Backported to 8.5.x because as @Wim Leers pointed out to me this
Comment #13
Wim Leers🎉
Thank you!