瀏覽代碼

popsu_migrate: D7NodeProjet textes ok

bach 4 年之前
父節點
當前提交
33131889dc

+ 1 - 1
config/sync/migrate_plus.migration.d7_allpublicfiles.yml

@@ -1,4 +1,4 @@
-uuid: 841402db-9c2a-490f-b9d8-b7635222ff7c
+uuid: 4237b2ff-70fb-49fb-ba08-0f001f0991ba
 langcode: fr
 status: true
 dependencies: {  }

+ 1 - 1
config/sync/migrate_plus.migration.d7_node_programme.yml

@@ -1,4 +1,4 @@
-uuid: 70ec992f-6317-4548-a0d5-7312d708049a
+uuid: c0bac785-7c45-4c1e-b85b-c91293effe30
 langcode: fr
 status: true
 dependencies: {  }

+ 3 - 2
config/sync/migrate_plus.migration.d7_node_projet.yml

@@ -1,9 +1,9 @@
-uuid: 9c90276c-fc70-4c57-b6c6-c6e019f399ea
+uuid: f3e5ae89-05fe-424d-a598-ded8d9195083
 langcode: fr
 status: true
 dependencies: {  }
 _core:
-  default_config_hash: Ao7_pCurVcLD722BrzKUfG6-hi5wqeGa55gblh-ILZE
+  default_config_hash: ZhPmGeAAZFpVWfMiinaONww3bqrHqNtc6XZUY9AFrac
 id: d7_node_projet
 class: null
 field_plugin_method: null
@@ -77,6 +77,7 @@ process:
         no_stub: true
       alt: alt
       title: title
+  field_textes: field_textes
   field_memo: field_memo
 destination:
   plugin: 'entity:node'

+ 1 - 1
config/sync/migrate_plus.migration.d7_node_theme.yml

@@ -1,4 +1,4 @@
-uuid: be024a37-e0f3-4133-874c-0618ef044101
+uuid: af264f84-4b51-4581-9a40-362dcbab3024
 langcode: fr
 status: true
 dependencies: {  }

+ 1 - 1
config/sync/migrate_plus.migration.d7_taxonomy_term_type_theme.yml

@@ -1,4 +1,4 @@
-uuid: 65728399-9895-4b60-ae00-a41ba9a9c7ae
+uuid: 84bde132-de79-451e-a63b-2266df24ac42
 langcode: fr
 status: true
 dependencies: {  }

+ 1 - 1
config/sync/migrate_plus.migration.d7_taxonomy_term_ville.yml

@@ -1,4 +1,4 @@
-uuid: 232f115d-07fa-4758-9984-0afd44bd7b05
+uuid: fa777f51-bc93-4f8e-849e-9106aaba3609
 langcode: fr
 status: true
 dependencies: {  }

+ 1 - 1
config/sync/migrate_plus.migration.d7_users.yml

@@ -1,4 +1,4 @@
-uuid: b4ee97e9-2597-465f-8342-f1722ba9fcfc
+uuid: 7329a02f-4e4a-4d7d-8902-c383d68655b0
 langcode: fr
 status: true
 dependencies: {  }

+ 1 - 1
config/sync/migrate_plus.migration_group.popsu.yml

@@ -1,4 +1,4 @@
-uuid: 3a602f8f-c61e-4156-a96e-5ae0630490d6
+uuid: 04096a5f-82bf-4c6d-be05-5272069b0845
 langcode: fr
 status: true
 dependencies:

+ 2 - 0
web/modules/custom/popsu_migrate/config/install/migrate_plus.migration.d7_node_projet.yml

@@ -89,6 +89,8 @@ process:
       alt: alt
       title: title
 
+  field_textes: field_textes
+
   field_memo: field_memo
 
 migration_dependencies:

+ 28 - 0
web/modules/custom/popsu_migrate/src/Plugin/migrate/source/D7NodeProjet.php

@@ -12,6 +12,7 @@ use Drupal\migrate\Plugin\MigrationInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Drupal\Core\Logger\LoggerChannelFactoryInterface;
 use Drush\Drush;
+use Drupal\paragraphs\Entity\Paragraph;
 
 // use Drupal\popsu_migrate\Plugin\migrate\source\D7Programme;
 
@@ -113,6 +114,7 @@ class D7NodeProjet extends FieldableEntity {
 
     $memo = '';
     $memo .= "#migration : old nid = ".$nid."\n";
+    $memo .= "#migration : old content type = ".$type."\n";
 
     // Get Field API field values.
     foreach ($this->getFields('node', $type) as $field_name => $field) {
@@ -276,6 +278,32 @@ class D7NodeProjet extends FieldableEntity {
       $row->setSourceProperty('diaporama', $field_diaporama);
     }
 
+    # Text paragraphe
+    $text_fields = array(
+      'field_popsu_projet_methodo' => 'Démarche & méthodologie',
+      'field_popsu_projet_demarche' => 'Chronologie',
+      'field_popsu_projet_programme' => 'Programme',
+    );
+    $textes_paragraphes = array();
+    foreach ($text_fields as $key => $title) {
+      if ($text = $row->getSourceProperty($key)){
+        $text[0]['format'] = 'wysiwyg';
+        $p = Paragraph::create(['type' => 'textes']);
+        $p->set('field_texte', $text)
+        ->set('field_titre', $title)
+        ->isNew();
+        $p->save();
+
+        $textes_paragraphes[] = array(
+          'target_id' => $p->id(),
+          'target_revision_id' => $p->getRevisionId(),
+        );
+      }
+    }
+    if (!empty($textes_paragraphes)) {
+      $row->setSourceProperty('field_textes', $textes_paragraphes);
+    }
+
     // record migration errors in field_memo
     if(isset($memo)){
       $field_memo = array(