popsu_migrate: D7NodeTheme textes paragraphes ok
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
			
		||||
uuid: ae496e79-c2b0-483b-9dc2-b04f29237322
 | 
			
		||||
uuid: f77d5481-ece0-47fe-b046-b69ab3876303
 | 
			
		||||
langcode: fr
 | 
			
		||||
status: true
 | 
			
		||||
dependencies: {  }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
uuid: 6fa024f8-38b0-48af-886a-e3f1575e8873
 | 
			
		||||
uuid: 05dac26f-a442-447f-b553-d3157114c7a6
 | 
			
		||||
langcode: fr
 | 
			
		||||
status: true
 | 
			
		||||
dependencies: {  }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
uuid: 935e3f08-247d-4c85-8a42-6c35daa0ddf7
 | 
			
		||||
uuid: cf67cd9d-0073-41be-95bf-7c0c2daeedd0
 | 
			
		||||
langcode: fr
 | 
			
		||||
status: true
 | 
			
		||||
dependencies: {  }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,9 @@
 | 
			
		||||
uuid: ff918ee4-59b1-4139-a96d-f68bd7036274
 | 
			
		||||
uuid: 621d7d2c-29c4-45e0-9896-816803c63290
 | 
			
		||||
langcode: fr
 | 
			
		||||
status: true
 | 
			
		||||
dependencies: {  }
 | 
			
		||||
_core:
 | 
			
		||||
  default_config_hash: zBJRTgJ9e5p4ZBc0jDlNp3eynstu43FtkG96jez6pQU
 | 
			
		||||
  default_config_hash: EdOWxg1l0qLqF0X4TENlfvyXrFipLu0vXvDh9P8sr4A
 | 
			
		||||
id: d7_node_theme
 | 
			
		||||
class: null
 | 
			
		||||
field_plugin_method: null
 | 
			
		||||
@@ -67,6 +67,7 @@ process:
 | 
			
		||||
        plugin: migration_lookup
 | 
			
		||||
        migration: d7_node_projet
 | 
			
		||||
        source: nid
 | 
			
		||||
  field_textes: field_textes
 | 
			
		||||
destination:
 | 
			
		||||
  plugin: 'entity:node'
 | 
			
		||||
migration_dependencies:
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
uuid: d8151c69-445f-489e-ac82-372fe5d5ca9e
 | 
			
		||||
uuid: 9b980c5a-4b23-4473-a165-15622e2a915e
 | 
			
		||||
langcode: fr
 | 
			
		||||
status: true
 | 
			
		||||
dependencies: {  }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
uuid: 1cea8a55-906b-4d00-81d8-a35ec6657e17
 | 
			
		||||
uuid: f0f36010-9331-4eb1-8d7c-fb9d73725774
 | 
			
		||||
langcode: fr
 | 
			
		||||
status: true
 | 
			
		||||
dependencies: {  }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
uuid: 06f1809a-7f86-4527-a5d7-1ad2ce7c71c7
 | 
			
		||||
uuid: 1c7ff499-a3e4-4009-950e-3e2a45c7b814
 | 
			
		||||
langcode: fr
 | 
			
		||||
status: true
 | 
			
		||||
dependencies:
 | 
			
		||||
 
 | 
			
		||||
@@ -74,6 +74,8 @@ process:
 | 
			
		||||
        migration: d7_node_projet
 | 
			
		||||
        source: nid
 | 
			
		||||
 | 
			
		||||
  field_textes: field_textes
 | 
			
		||||
 | 
			
		||||
migration_dependencies:
 | 
			
		||||
  required:
 | 
			
		||||
    - d7_allpublicfiles
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 | 
			
		||||
@@ -180,7 +181,7 @@ class D7NodeTheme extends FieldableEntity {
 | 
			
		||||
          ->condition('n.type', ['popsu_theme_local', 'popsu_projet'], 'IN');
 | 
			
		||||
        $res = $q->execute()->fetchAll();
 | 
			
		||||
        if (!empty($res)) {
 | 
			
		||||
          Drush::output()->writeln(dump($res));
 | 
			
		||||
          // Drush::output()->writeln(dump($res));
 | 
			
		||||
          switch ($res[0]['type']) {
 | 
			
		||||
            case 'popsu_theme_local':
 | 
			
		||||
              $field_themes_lies[] = $value;
 | 
			
		||||
@@ -202,11 +203,43 @@ class D7NodeTheme extends FieldableEntity {
 | 
			
		||||
      // Drush::output()->writeln(dump($field_themes_lies));
 | 
			
		||||
      $row->setSourceProperty('field_themes_lies', $field_themes_lies);
 | 
			
		||||
    }
 | 
			
		||||
    // TODO: missing popsu_villes popsu europe ... ?
 | 
			
		||||
    if (!empty($field_projets_lies)) {
 | 
			
		||||
      // Drush::output()->writeln(dump($field_themes_lies));
 | 
			
		||||
      $row->setSourceProperty('field_projets_lies', $field_projets_lies);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    # Text paragraphe
 | 
			
		||||
    $text_fields = array(
 | 
			
		||||
      'field_popsu_themtrans_body' => 'Texte d\'introduction court',
 | 
			
		||||
      'field_popsu_themtrans_introlong' => 'Texte d\'introduction long',
 | 
			
		||||
      'field_popsu_themloc_body' => 'Texte de présentation du thème',
 | 
			
		||||
      'field_popsu_themeur_titleshort' => 'Version courte de l’intitulé',
 | 
			
		||||
      'field_popsu_themeur_title_format' => 'Version formatée de l’intitulé',
 | 
			
		||||
      'field_popsu_themeur_intro' => 'texted’introduction',
 | 
			
		||||
      'field_popsu_themloc_demarche' => 'Démarche & méthodologie',
 | 
			
		||||
      'field_popsu_themtrans_reponses' => 'Réponsesauquestionnaire'
 | 
			
		||||
    );
 | 
			
		||||
    $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);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return parent::prepareRow($row);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user