protected function EntityLanguageTestBase::toggleFieldTranslatability in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php \Drupal\KernelTests\Core\Entity\EntityLanguageTestBase::toggleFieldTranslatability()
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php \Drupal\KernelTests\Core\Entity\EntityLanguageTestBase::toggleFieldTranslatability()
Toggles field storage translatability.
Parameters
string $entity_type: The type of the entity fields are attached to.
string $bundle: The bundle of the entity.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityLanguageTestBase.php, line 124
Class
- EntityLanguageTestBase
- Base class for language-aware entity tests.
Namespace
Drupal\KernelTests\Core\EntityCode
protected function toggleFieldTranslatability($entity_type, $bundle) {
$fields = [
$this->fieldName,
$this->untranslatableFieldName,
];
foreach ($fields as $field_name) {
$field = FieldConfig::loadByName($entity_type, $bundle, $field_name);
$translatable = !$field
->isTranslatable();
$field
->set('translatable', $translatable);
$field
->save();
$field = FieldConfig::loadByName($entity_type, $bundle, $field_name);
$this
->assertEquals($translatable, $field
->isTranslatable(), 'Field translatability changed.');
}
\Drupal::cache('entity')
->deleteAll();
}