diff --git a/core/modules/content_moderation/content_moderation.module b/core/modules/content_moderation/content_moderation.module index b67fbd3dfc60f6a1573204e020ada4b4418e0b6d..0dc03bf8a9ee12d4803ccfc7e22662fa123f849d 100644 --- a/core/modules/content_moderation/content_moderation.module +++ b/core/modules/content_moderation/content_moderation.module @@ -262,3 +262,13 @@ function content_moderation_workflow_insert(WorkflowInterface $entity) { function content_moderation_workflow_update(WorkflowInterface $entity) { content_moderation_workflow_insert($entity); } + +/** + * Implements hook_rest_resource_alter(). + */ +function content_moderation_rest_resource_alter(&$definitions) { + // ContentModerationState is an internal entity type. Therefore it should not + // be exposed via REST. + // @see \Drupal\content_moderation\ContentModerationStateAccessControlHandler + unset($definitions['entity:content_moderation_state']); +} diff --git a/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateResourceTest.php b/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateResourceTest.php new file mode 100644 index 0000000000000000000000000000000000000000..cc09e5921a71ec728804c2f57f81a96890765d6a --- /dev/null +++ b/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateResourceTest.php @@ -0,0 +1,38 @@ +setExpectedException(PluginNotFoundException::class, 'The "entity:content_moderation_state" plugin does not exist.'); + RestResourceConfig::create([ + 'id' => 'entity.content_moderation_state', + 'granularity' => RestResourceConfigInterface::RESOURCE_GRANULARITY, + 'configuration' => [ + 'methods' => ['GET'], + 'formats' => ['json'], + 'authentication' => ['cookie'], + ], + ]) + ->enable() + ->save(); + } + +}