protected function ContentTranslationMetadataWrapper::setFieldOnlyIfTranslatable in Drupal 10
Same name and namespace in other branches
- 8 core/modules/content_translation/src/ContentTranslationMetadataWrapper.php \Drupal\content_translation\ContentTranslationMetadataWrapper::setFieldOnlyIfTranslatable()
- 9 core/modules/content_translation/src/ContentTranslationMetadataWrapper.php \Drupal\content_translation\ContentTranslationMetadataWrapper::setFieldOnlyIfTranslatable()
Updates a field value, only if the field is translatable.
Parameters
string $field_name: The name of the field.
mixed $value: The field value to be set.
File
- core/
modules/ content_translation/ src/ ContentTranslationMetadataWrapper.php, line 144
Class
- ContentTranslationMetadataWrapper
- Base class for content translation metadata wrappers.
Namespace
Drupal\content_translationCode
protected function setFieldOnlyIfTranslatable($field_name, $value) {
if ($this->translation
->getFieldDefinition($field_name)
->isTranslatable()) {
$this->translation
->set($field_name, $value);
}
}