function LanguageTestTrait::enableBundleTranslation

Same name in other branches
  1. 10 core/modules/language/tests/src/Traits/LanguageTestTrait.php \Drupal\Tests\language\Traits\LanguageTestTrait::enableBundleTranslation()

Enables translations 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.

Return value

\Drupal\language\ContentLanguageSettingsInterface The saved content language config entity.

5 calls to LanguageTestTrait::enableBundleTranslation()
ContactLanguageTest::testContactLanguage in core/modules/contact/tests/src/Functional/ContactLanguageTest.php
Tests configuration options with language enabled.
ContentTranslationTestTrait::enableContentTranslation in core/modules/content_translation/tests/src/Traits/ContentTranslationTestTrait.php
Enables content translation for the given entity type bundle.
MenuUiContentTranslationTest::setUp in core/modules/menu_ui/tests/src/Functional/MenuUiContentTranslationTest.php
NodeTranslationUITest::setUp in core/modules/node/tests/src/Functional/NodeTranslationUITest.php
SearchMultilingualTest::testMultilingualSearchFilter in core/modules/views/tests/src/Functional/SearchMultilingualTest.php
Tests search with multilingual nodes.

File

core/modules/language/tests/src/Traits/LanguageTestTrait.php, line 49

Class

LanguageTestTrait
Provides an API to programmatically manage languages in tests.

Namespace

Drupal\Tests\language\Traits

Code

public static function enableBundleTranslation(string $entity_type_id, string $bundle, ?string $default_langcode = LanguageInterface::LANGCODE_SITE_DEFAULT) : ContentLanguageSettingsInterface {
    $content_language_settings = ContentLanguageSettings::loadByEntityTypeBundle($entity_type_id, $bundle)->setDefaultLangcode($default_langcode)
        ->setLanguageAlterable(TRUE);
    $content_language_settings->save();
    return $content_language_settings;
}

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