From 63eeda5c44823d17320b3556f2f4fb92765111c3 Mon Sep 17 00:00:00 2001 From: Harings Rob Date: Sun, 22 Jan 2017 11:47:51 +0100 Subject: [PATCH] #29 removve old migrate classes --- .../integration_migrate.module | 6 - modules/src/AbstractMigration.php | 119 ------------------ modules/src/DocumentWrapper.php | 74 ----------- modules/src/DocumentWrapperInterface.php | 57 --------- modules/src/MigrateItemJSON.php | 28 ----- modules/src/MigrateListJSON.php | 30 ----- 6 files changed, 314 deletions(-) delete mode 100644 modules/integration_migrate/integration_migrate.module delete mode 100644 modules/src/AbstractMigration.php delete mode 100644 modules/src/DocumentWrapper.php delete mode 100644 modules/src/DocumentWrapperInterface.php delete mode 100644 modules/src/MigrateItemJSON.php delete mode 100644 modules/src/MigrateListJSON.php diff --git a/modules/integration_migrate/integration_migrate.module b/modules/integration_migrate/integration_migrate.module deleted file mode 100644 index 6d6ea4b..0000000 --- a/modules/integration_migrate/integration_migrate.module +++ /dev/null @@ -1,6 +0,0 @@ -getDestination()->getEntityType(); - if (module_exists('entity_translation')) { - if (entity_translation_enabled($entity_type)) { - $this->saveTranslations($entity, $source_row); - } - } - - // Make sure that path aliases are generated for all available languages. - // Only works if Migrate field "pathauto" is enabled. - // Check PathautoMigrationHandler class for more information. - if (module_exists('pathauto')) { - $mappings = $this->getFieldMappings(); - if (isset($mappings['pathauto']) && $mappings['pathauto']->getDefaultValue()) { - $function = "pathauto_{$entity_type}_update_alias"; - if (function_exists($function)) { - foreach ($source_row->getAvailableLanguages() as $language) { - $function($entity, 'update', ['language' => $language]); - } - } - } - } - } - - /** - * Save field translations for the specified entity. - * - * @param object $entity - * Entity object. - * @param DocumentWrapperInterface $source_row - * Source row, as expected by Migrate class. - */ - private function saveTranslations($entity, DocumentWrapperInterface $source_row) { - - foreach ($source_row->getAvailableLanguages() as $language) { - - if ($language != $source_row->getDefaultLanguage()) { - - $source_row->setSourceValues($language); - $this->sourceValues = $source_row; - $this->prepareRow($this->sourceValues); - $this->applyMappings(); - - // Prepare entity in order to correctly apply mappings in prepare(). - $new_entity = clone $entity; - foreach ((array) $this->destinationValues as $field_name => $value) { - $new_entity->$field_name = $value; - } - $this->getDestination()->prepare($new_entity, $this->sourceValues); - - $entity_type = $this->getDestination()->getEntityType(); - $bundle_name = $this->getDestination()->getBundle(); - - $values = []; - $field_instances = field_info_instances($entity_type, $bundle_name); - foreach ($field_instances as $field_name => $field_instance) { - if (isset($this->destinationValues->$field_name)) { - $values[$field_name] = $new_entity->$field_name; - } - } - - // Apply translations, moving this into a separate method. - $translation_handler = entity_translation_get_handler($entity_type, $entity); - - // Load translations. - $translation_handler->loadTranslations(); - - $translation = [ - 'translate' => 0, - 'status' => TRUE, - 'language' => $language, - 'source' => $entity->translations->original, - 'changed' => time(), - ]; - - // Content based translation. - if ($entity_type == 'node' && entity_translation_node_supported_type($entity->type)) { - $translation['uid'] = $entity->uid; - $translation['created'] = $entity->created; - $translation['changed'] = $entity->changed; - } - - // Add the new translation and store it. - // @link https://www.drupal.org/node/1069774#comment-4127006 - $translation_handler->setTranslation($translation, $values); - field_attach_update($entity_type, $entity); - } - } - } - -} diff --git a/modules/src/DocumentWrapper.php b/modules/src/DocumentWrapper.php deleted file mode 100644 index 45d920c..0000000 --- a/modules/src/DocumentWrapper.php +++ /dev/null @@ -1,74 +0,0 @@ -setDocument($document); - $this->setSourceValues(); - } - - /** - * {@inheritdoc} - */ - private function setDocument(DocumentInterface $document = NULL) { - $this->document = $document; - } - - /** - * {@inheritdoc} - */ - public function getDocument() { - return $this->document; - } - - /** - * {@inheritdoc} - */ - public function getAvailableLanguages() { - return $this->getDocument()->getAvailableLanguages(); - } - - /** - * {@inheritdoc} - */ - public function getDefaultLanguage() { - return $this->getDocument()->getDefaultLanguage(); - } - - /** - * {@inheritdoc} - */ - public function setSourceValues($language = NULL) { - $language = $language ? $language : $this->getDocument()->getDefaultLanguage(); - $this->getDocument()->setCurrentLanguage($language); - $this->_id = $this->getDocument()->getId(); - $this->default_language = $language; - foreach ($this->getDocument()->getCurrentLanguageFieldsValues() as $field_name => $value) { - $this->{$field_name} = $value; - } - } - -} diff --git a/modules/src/DocumentWrapperInterface.php b/modules/src/DocumentWrapperInterface.php deleted file mode 100644 index e22331d..0000000 --- a/modules/src/DocumentWrapperInterface.php +++ /dev/null @@ -1,57 +0,0 @@ -