function ContentTranslationMetadataWrapper::setPublished

Same name and namespace in other branches
  1. 9 core/modules/content_translation/src/ContentTranslationMetadataWrapper.php \Drupal\content_translation\ContentTranslationMetadataWrapper::setPublished()
  2. 8.9.x core/modules/content_translation/src/ContentTranslationMetadataWrapper.php \Drupal\content_translation\ContentTranslationMetadataWrapper::setPublished()
  3. 11.x core/modules/content_translation/src/ContentTranslationMetadataWrapper.php \Drupal\content_translation\ContentTranslationMetadataWrapper::setPublished()

Sets the translation published status.

The metadata field will be updated, only if it's translatable.

Parameters

bool $published: TRUE if the translation is published, FALSE otherwise.

Return value

$this

Overrides ContentTranslationMetadataWrapperInterface::setPublished

File

core/modules/content_translation/src/ContentTranslationMetadataWrapper.php, line 97

Class

ContentTranslationMetadataWrapper
Base class for content translation metadata wrappers.

Namespace

Drupal\content_translation

Code

public function setPublished($published) {
    $field_name = $this->translation
        ->hasField('content_translation_status') ? 'content_translation_status' : 'status';
    $this->setFieldOnlyIfTranslatable($field_name, $published);
    return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.