1

I'm trying to find out if a type of content (not a node) is being moderated. How can I determine it?

For example:

function MY_MODULE_form_node_type_form_alter(&$form, FormStateInterface $form_state, $form_id) {
   $content_type = $form_state->getFormObject()->getEntity(); // $content_type is a Drupal\node\Entity\NodeType
}

I can't find a way to find out if this type of content is being moderated by some type of workflow.

1
  • You sure you are not mixing up terms? Content type is a bundle to be used for many nodes and a content type can't be moderated as far as I know. But nodes can. And they then are connected to a moderation state entity I think.
    – leymannx
    Commented Dec 11, 2019 at 19:36

1 Answer 1

1

You should be able to get that from ModerationInformation:: shouldModerateEntitiesOfBundle(), via the content_moderation.moderation_information service:

$moderation_info = \Drupal::service('content_moderation.moderation_information');
$entity_type = \Drupal::entityTypeManager()->getDefinition('node');
if ($moderation_info->shouldModerateEntitiesOfBundle($entity_type, $content_type->id())) {
  // ...
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.