You are here

protected function ContentTranslationMetadataWrapper::setFieldOnlyIfTranslatable in Zircon Profile 8

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

4 calls to ContentTranslationMetadataWrapper::setFieldOnlyIfTranslatable()
ContentTranslationMetadataWrapper::setAuthor in core/modules/content_translation/src/ContentTranslationMetadataWrapper.php
Sets the translation author.
ContentTranslationMetadataWrapper::setChangedTime in core/modules/content_translation/src/ContentTranslationMetadataWrapper.php
Sets the translation modification timestamp.
ContentTranslationMetadataWrapper::setCreatedTime in core/modules/content_translation/src/ContentTranslationMetadataWrapper.php
Sets the translation creation timestamp.
ContentTranslationMetadataWrapper::setPublished in core/modules/content_translation/src/ContentTranslationMetadataWrapper.php
Sets the translation published status.

File

core/modules/content_translation/src/ContentTranslationMetadataWrapper.php, line 149
Contains \Drupal\content_translation\ContentTranslationMetadataWrapper.

Class

ContentTranslationMetadataWrapper
Base class for content translation metadata wrappers.

Namespace

Drupal\content_translation

Code

protected function setFieldOnlyIfTranslatable($field_name, $value) {
  if ($this->translation
    ->getFieldDefinition($field_name)
    ->isTranslatable()) {
    $this->translation
      ->set($field_name, $value);
  }
}