You are here

public function EntityTypeInfo::entityTypeAlter in Drupal 9

Same name in this branch
  1. 9 core/modules/content_moderation/src/EntityTypeInfo.php \Drupal\content_moderation\EntityTypeInfo::entityTypeAlter()
  2. 9 core/modules/workspaces/src/EntityTypeInfo.php \Drupal\workspaces\EntityTypeInfo::entityTypeAlter()
Same name and namespace in other branches
  1. 8 core/modules/content_moderation/src/EntityTypeInfo.php \Drupal\content_moderation\EntityTypeInfo::entityTypeAlter()

Adds Moderation configuration to appropriate entity types.

Parameters

\Drupal\Core\Entity\EntityTypeInterface[] $entity_types: The master entity type list to alter.

See also

hook_entity_type_alter()

File

core/modules/content_moderation/src/EntityTypeInfo.php, line 132

Class

EntityTypeInfo
Manipulates entity type information.

Namespace

Drupal\content_moderation

Code

public function entityTypeAlter(array &$entity_types) {
  foreach ($entity_types as $entity_type_id => $entity_type) {

    // Internal entity types should never be moderated, and the 'path_alias'
    // entity type needs to be excluded for now.
    // @todo Enable moderation for path aliases after they become publishable
    //   in https://www.drupal.org/project/drupal/issues/3007669.
    // Workspace entities can not be moderated because they use string IDs.
    // @see \Drupal\content_moderation\Entity\ContentModerationState::baseFieldDefinitions()
    // where the target entity ID is defined as an integer.
    // @todo Moderation is disabled for taxonomy terms until integration is
    //   enabled for them.
    // @see https://www.drupal.org/project/drupal/issues/3047110
    $entity_type_to_exclude = [
      'path_alias',
      'workspace',
      'taxonomy_term',
    ];
    if ($entity_type
      ->isRevisionable() && !$entity_type
      ->isInternal() && !in_array($entity_type_id, $entity_type_to_exclude)) {
      $entity_types[$entity_type_id] = $this
        ->addModerationToEntityType($entity_type);
    }
  }
}