function LanguageTestTrait::setFieldTranslatable

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

Sets and saves a given field instance translation status.

Parameters

string $entity_type_id: The ID of the entity type.

string $bundle: The bundle name.

string $field_name: The name of the field.

bool $status: Whether the field should be translatable or not.

7 calls to LanguageTestTrait::setFieldTranslatable()
ContentTranslationUntranslatableFieldsTest::setUp in core/modules/content_translation/tests/src/Functional/ContentTranslationUntranslatableFieldsTest.php
FileOnTranslatedEntityTest::setUp in core/modules/file/tests/src/Functional/FileOnTranslatedEntityTest.php
ImageOnTranslatedEntityTest::testSyncedImages in core/modules/image/tests/src/Functional/ImageOnTranslatedEntityTest.php
Tests synced file fields on translated nodes.
NodeTranslationUITest::testDetailsTitleIsNotEscaped in core/modules/node/tests/src/Functional/NodeTranslationUITest.php
Tests title is not escaped (but XSS-filtered) for details form element.
PathLanguageTest::setUp in core/modules/path/tests/src/Functional/PathLanguageTest.php

... See full list

File

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

Class

LanguageTestTrait
Provides an API to programmatically manage languages in tests.

Namespace

Drupal\Tests\language\Traits

Code

public static function setFieldTranslatable(string $entity_type_id, string $bundle, string $field_name, bool $status) : void {
    FieldConfig::loadByName($entity_type_id, $bundle, $field_name)->setTranslatable($status)
        ->save();
}

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