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

Breadcrumb

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

function EntityContentBase::rollback

Overrides Entity::rollback

1 method overrides EntityContentBase::rollback()
EntityContentComplete::rollback in core/modules/migrate/src/Plugin/migrate/destination/EntityContentComplete.php
Delete the specified destination object from the target Drupal.

File

core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php, line 366

Class

EntityContentBase
Provides destination class for all content entities lacking a specific class.

Namespace

Drupal\migrate\Plugin\migrate\destination

Code

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

API Navigation

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