function ContentEntityStorageBase::populateAffectedRevisionTranslations

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::populateAffectedRevisionTranslations()
  2. 8.9.x core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::populateAffectedRevisionTranslations()
  3. 11.x core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::populateAffectedRevisionTranslations()

Populates the affected flag for all the revision translations.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: An entity object being saved.

1 call to ContentEntityStorageBase::populateAffectedRevisionTranslations()
ContentEntityStorageBase::doSave in core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php
Performs storage-specific saving of the entity.

File

core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php, line 1030

Class

ContentEntityStorageBase
Base class for content entity storage handlers.

Namespace

Drupal\Core\Entity

Code

protected function populateAffectedRevisionTranslations(ContentEntityInterface $entity) {
    if ($this->entityType
        ->isTranslatable() && $this->entityType
        ->isRevisionable()) {
        $languages = $entity->getTranslationLanguages();
        foreach ($languages as $langcode => $language) {
            $translation = $entity->getTranslation($langcode);
            $current_affected = $translation->isRevisionTranslationAffected();
            if (!isset($current_affected) || $entity->isNewRevision() && !$translation->isRevisionTranslationAffectedEnforced()) {
                // When setting the revision translation affected flag we have to
                // explicitly set it to not be enforced. By default it will be
                // enforced automatically when being set, which allows us to determine
                // if the flag has been already set outside the storage in which case
                // we should not recompute it.
                // @see \Drupal\Core\Entity\ContentEntityBase::setRevisionTranslationAffected().
                $new_affected = $translation->hasTranslationChanges() ? TRUE : NULL;
                $translation->setRevisionTranslationAffected($new_affected);
                $translation->setRevisionTranslationAffectedEnforced(FALSE);
            }
        }
    }
}

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