/**
  * Constructs a content entity.
  *
  * @param array $configuration
  *   A configuration array containing information about the plugin instance.
  * @param string $plugin_id
  *   The plugin ID for the plugin instance.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\migrate\Entity\MigrationInterface $migration
  *   The migration entity.
  * @param \Drupal\Core\Entity\EntityStorageInterface $storage
  *   The storage for this entity type.
  * @param array $bundles
  *   The list of bundles this entity type has.
  * @param \Drupal\migrate\Plugin\MigratePluginManager $plugin_manager
  *   The plugin manager.
  * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
  *   The entity manager service.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles);
     $this->entityManager = $entity_manager;
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 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->save();
                         }
                     }
                 }
             }
         }
     } else {
         parent::rollback($destination_identifier);
     }
 }