function EntityContentBase::rollback
Overrides Entity::rollback
1 method overrides EntityContentBase::rollback()
- EntityContentComplete::rollback in core/modules/ migrate/ src/ Plugin/ migrate/ destination/ EntityContentComplete.php 
File
- 
              core/modules/ migrate/ src/ Plugin/ migrate/ destination/ EntityContentBase.php, line 382 
Class
- EntityContentBase
- Provides destination class for all content entities lacking a specific class.
Namespace
Drupal\migrate\Plugin\migrate\destinationCode
public function rollback(array $destination_identifier) {
  if ($this->isTranslationDestination()) {
    // Attempt to remove the translation.
    $entity = $this->storage
      ->load(reset($destination_identifier));
    if ($entity && $entity instanceof TranslatableInterface) {
      if ($key = $this->getKey('langcode')) {
        if (isset($destination_identifier[$key])) {
          $langcode = $destination_identifier[$key];
          if ($entity->hasTranslation($langcode)) {
            // Make sure we don't remove the default translation.
            $translation = $entity->getTranslation($langcode);
            if (!$translation->isDefaultTranslation()) {
              $entity->removeTranslation($langcode);
              $entity->setSyncing(TRUE);
              $entity->save();
            }
          }
        }
      }
    }
  }
  else {
    parent::rollback($destination_identifier);
  }
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
