function LanguageTestTrait::setFieldTranslatable

Same name and namespace in other branches
  1. 11.x 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.

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

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.