function ContentTranslationTestTrait::enableContentTranslation

Same name and namespace in other branches
  1. 11.x core/modules/content_translation/tests/src/Traits/ContentTranslationTestTrait.php \Drupal\Tests\content_translation\Traits\ContentTranslationTestTrait::enableContentTranslation()

Enables content translation for the given entity type bundle.

Parameters

string $entity_type_id: The ID of the entity type.

string $bundle: The bundle name.

string|null $default_langcode: The language code to use as the default language.

1 call to ContentTranslationTestTrait::enableContentTranslation()
PathWithNodeAccessGrantsTest::setUp in core/modules/path/tests/src/Functional/PathWithNodeAccessGrantsTest.php

File

core/modules/content_translation/tests/src/Traits/ContentTranslationTestTrait.php, line 27

Class

ContentTranslationTestTrait
Provides an API to programmatically manage content translation in tests.

Namespace

Drupal\Tests\content_translation\Traits

Code

public function enableContentTranslation(string $entity_type_id, string $bundle, ?string $default_langcode = LanguageInterface::LANGCODE_SITE_DEFAULT) : void {
  static::enableBundleTranslation($entity_type_id, $bundle, $default_langcode);
  $content_translation_manager = $this->container
    ->get('content_translation.manager');
  $content_translation_manager->setEnabled($entity_type_id, $bundle, TRUE);
  $content_translation_manager->setBundleTranslationSettings($entity_type_id, $bundle, [
    'untranslatable_fields_hide' => FALSE,
  ]);
}

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