You are here

function comment_test_entity_type_alter in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/comment/tests/modules/comment_test/comment_test.module \comment_test_entity_type_alter()

Implements hook_entity_type_alter().

File

core/modules/comment/tests/modules/comment_test/comment_test.module, line 15
Dummy module implementing comment related hooks to test API interaction with the Comment module.

Code

function comment_test_entity_type_alter(array &$entity_types) {

  /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
  if (\Drupal::languageManager()
    ->isMultilingual()) {

    // Enable language handling for comment fields.
    $translation = $entity_types['comment']
      ->get('translation');
    $translation['comment_test'] = TRUE;
    $entity_types['comment']
      ->set('translation', $translation);
  }
}