function content_moderation_entity_bundle_info_alter

Implements hook_entity_bundle_info_alter().

File

core/modules/content_moderation/content_moderation.module, line 365

Code

function content_moderation_entity_bundle_info_alter(&$bundles) {
  $translatable = FALSE;
  /** @var \Drupal\workflows\WorkflowInterface $workflow */
  foreach (Workflow::loadMultipleByType('content_moderation') as $workflow) {
    /** @var \Drupal\content_moderation\Plugin\WorkflowType\ContentModeration $plugin */
    $plugin = $workflow->getTypePlugin();
    foreach ($plugin->getEntityTypes() as $entity_type_id) {
      foreach ($plugin->getBundlesForEntityType($entity_type_id) as $bundle_id) {
        if (isset($bundles[$entity_type_id][$bundle_id])) {
          $bundles[$entity_type_id][$bundle_id]['workflow'] = $workflow->id();
          // If we have even one moderation-enabled translatable bundle, we need
          // to make the moderation state bundle translatable as well, to enable
          // the revision translation merge logic also for content moderation
          // state revisions.
          if (!empty($bundles[$entity_type_id][$bundle_id]['translatable'])) {
            $translatable = TRUE;
          }
        }
      }
    }
  }
  $bundles['content_moderation_state']['content_moderation_state']['translatable'] = $translatable;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.