Browse Source

migration node materiau: field_index, field_reference

Bachir Soussi Chiadmi 5 years ago
parent
commit
b8f572a83e

+ 1 - 1
composer.json

@@ -7,7 +7,7 @@
         "composer/installers": "^1.0.24",
         "wikimedia/composer-merge-plugin": "^1.4",
         "drupal/migrate_plus": "^4.0",
-        "drupal/migrate_tools": "^4.0",
+        "drupal/migrate_tools": "4.x-dev",
         "drupal/config_devel": "^1.2",
         "drupal/examples": "1.x-dev",
         "drupal/synonyms": "1.x-dev",

+ 10 - 14
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "1c2031518d90d8efedbecea6a76848c4",
+    "content-hash": "feb474307bb454795da76ad5e40b4825",
     "packages": [
         {
             "name": "alchemy/zippy",
@@ -5317,17 +5317,11 @@
         },
         {
             "name": "drupal/migrate_tools",
-            "version": "4.0.0",
+            "version": "dev-4.x",
             "source": {
                 "type": "git",
                 "url": "https://git.drupal.org/project/migrate_tools",
-                "reference": "8.x-4.0"
-            },
-            "dist": {
-                "type": "zip",
-                "url": "https://ftp.drupal.org/files/projects/migrate_tools-8.x-4.0.zip",
-                "reference": "8.x-4.0",
-                "shasum": "016dfb010df76723c5a6a447921fdccd3c885237"
+                "reference": "9fc2977a80ad46dab0caa11682d269fe3bfe4985"
             },
             "require": {
                 "drupal/core": "^8.3",
@@ -5343,11 +5337,11 @@
                     "dev-4.x": "4.x-dev"
                 },
                 "drupal": {
-                    "version": "8.x-4.0",
-                    "datestamp": "1535380084",
+                    "version": "8.x-4.0+4-dev",
+                    "datestamp": "1540829581",
                     "security-coverage": {
-                        "status": "covered",
-                        "message": "Covered by Drupal's security advisory policy"
+                        "status": "not-covered",
+                        "message": "Dev releases are not covered by Drupal security advisories."
                     }
                 },
                 "drush": {
@@ -5380,7 +5374,8 @@
                 "source": "http://cgit.drupalcode.org/migrate_tools",
                 "issues": "http://drupal.org/project/migrate_tools",
                 "irc": "irc://irc.freenode.org/drupal-migrate"
-            }
+            },
+            "time": "2018-11-06T14:19:48+00:00"
         },
         {
             "name": "drupal/pagerer",
@@ -12377,6 +12372,7 @@
     "aliases": [],
     "minimum-stability": "dev",
     "stability-flags": {
+        "drupal/migrate_tools": 20,
         "drupal/examples": 20,
         "drupal/synonyms": 20,
         "drupal/telephone_formatter": 10,

+ 8 - 0
modules/custom/materio_id/materio_id.module

@@ -2,6 +2,11 @@
 
 
 function computed_field_field_index_compute($entity_type_manager, $entity, $fields, $delta){
+  // drush_print($entity->field_index->value);
+  if (!empty($entity->field_index->value)) {  // the node is not new
+	  return $entity->field_index->value;
+	}
+
 
   /* FROM D7
 
@@ -61,6 +66,9 @@ function computed_field_field_index_compute($entity_type_manager, $entity, $fiel
 // }
 
 function computed_field_field_reference_compute($entity_type_manager, $entity, $fields, $delta) {
+  if (!empty($entity->field_reference->value)) {  // the node is not new
+    return $entity->field_reference->value;
+  }
 
   /* FROM D7
 

+ 3 - 4
modules/custom/materio_migrate/config/install/migrate_plus.migration.d7_node_materiau.yml

@@ -118,10 +118,9 @@ process:
           no_stub: true
         # there is no description field filled
         description: description
-
-  # field_famille: field_famille
-  # field_index: field_identifiant
-  # field_reference: field_reference_materio
+  field_famille: field_famille
+  field_index: field_identifiant
+  field_reference: field_reference_materio
 
   # just archives
   # : field_localisation

+ 3 - 0
modules/custom/materio_migrate/src/Plugin/migrate/source/D7NodeMateriau.php

@@ -147,6 +147,9 @@ class D7NodeMateriau extends FieldableEntity {
     }
     $row->setSourceProperty('linked_breves', $linked_breves);
 
+    // print_r($row->getSourceProperty('field_identifiant'));
+    // print_r($row->getSourceProperty('field_reference_materio'));
+
 
     // Make sure we always have a translation set.
     if ($row->getSourceProperty('tnid') == 0) {