Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ContentTranslationMetadataWrapper.php

function 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 144

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);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal