popsu_migrate: D7ParagrapheTextsProgramme replaced by on the fly paragraphe creation
This commit is contained in:
parent
65b11b15e4
commit
eba6068747
@ -40,17 +40,27 @@ process:
|
|||||||
default_value: 'wysiwyg'
|
default_value: 'wysiwyg'
|
||||||
|
|
||||||
# https://understanddrupal.com/articles/introduction-paragraphs-migrations-drupal
|
# https://understanddrupal.com/articles/introduction-paragraphs-migrations-drupal
|
||||||
pseudo_field_textes:
|
# pseudo_field_textes:
|
||||||
plugin: migration_lookup
|
# plugin: migration_lookup
|
||||||
migration: d7_paragraphe_texts_programme
|
# migration: d7_paragraphe_texts_programme
|
||||||
source: text_paragraphe_id
|
# source: text_paragraphe_id
|
||||||
field_textes:
|
# field_textes:
|
||||||
plugin: sub_process
|
# plugin: sub_process
|
||||||
source:
|
# source:
|
||||||
- '@pseudo_field_textes'
|
# - '@pseudo_field_textes'
|
||||||
process:
|
# process:
|
||||||
target_id: '0'
|
# target_id: '0'
|
||||||
target_revision_id: '1'
|
# target_revision_id: '1'
|
||||||
|
|
||||||
|
# field_textes:
|
||||||
|
# plugin: sub_process
|
||||||
|
# source:
|
||||||
|
# - text_paragraphe
|
||||||
|
# process:
|
||||||
|
# target_id: '0'
|
||||||
|
# target_revision_id: '1'
|
||||||
|
|
||||||
|
field_textes: text_paragraphe
|
||||||
|
|
||||||
# field_popsu_special_insert_intro
|
# field_popsu_special_insert_intro
|
||||||
# field_popsu_special_insert
|
# field_popsu_special_insert
|
||||||
@ -75,4 +85,3 @@ migration_dependencies:
|
|||||||
required:
|
required:
|
||||||
- d7_allpublicfiles
|
- d7_allpublicfiles
|
||||||
- d7_users
|
- d7_users
|
||||||
- d7_paragraphe_texts_programme
|
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
id: d7_paragraphe_texts_programme
|
|
||||||
label: Paragraphe texts Programme
|
|
||||||
migration_group: popsu
|
|
||||||
audit: true
|
|
||||||
migration_tags:
|
|
||||||
- Drupal 7
|
|
||||||
- Content
|
|
||||||
- Popsu
|
|
||||||
|
|
||||||
source:
|
|
||||||
plugin: d7_paragraphe_texts_programme
|
|
||||||
node_type: popsu_special
|
|
||||||
batch_size: 500
|
|
||||||
ids:
|
|
||||||
nid:
|
|
||||||
type: integer
|
|
||||||
|
|
||||||
destination:
|
|
||||||
plugin: 'entity_reference_revisions:paragraph'
|
|
||||||
default_bundle: textes
|
|
||||||
|
|
||||||
process:
|
|
||||||
# created: created
|
|
||||||
# changed: changed
|
|
||||||
|
|
||||||
uid:
|
|
||||||
plugin: default_value
|
|
||||||
default_value: 34
|
|
||||||
|
|
||||||
'field_texte/value': text
|
|
||||||
'field_texte/summary': text_summary
|
|
||||||
|
|
||||||
field_titre: title
|
|
||||||
|
|
||||||
migration_dependencies:
|
|
||||||
required:
|
|
||||||
- d7_allpublicfiles
|
|
||||||
- d7_users
|
|
@ -12,25 +12,11 @@ dependencies:
|
|||||||
# - drupal:migrate_drupal_multilingual
|
# - drupal:migrate_drupal_multilingual
|
||||||
# - drupal:field_group_migrate
|
# - drupal:field_group_migrate
|
||||||
|
|
||||||
|
# USING ```drush dre popsu_migrate``` instead of that
|
||||||
# https://www.liip.ch/en/blog/using-the-new-drupal-8-migration-api-module
|
# https://www.liip.ch/en/blog/using-the-new-drupal-8-migration-api-module
|
||||||
config_devel:
|
# config_devel:
|
||||||
install:
|
# install:
|
||||||
- migrate_plus.migration_group.d7_popsu
|
# - migrate_plus.migration_group.d7_popsu
|
||||||
- migrate_plus.migration.d7_allpublicfiles
|
# - migrate_plus.migration.d7_allpublicfiles
|
||||||
# - migrate_plus.migration.d7_users
|
# - migrate_plus.migration.d7_users
|
||||||
# - migrate_plus.migration.d7_taxonomy_term_company
|
# - migrate_plus.migration.d7_node_programme
|
||||||
# - migrate_plus.migration.d7_uc_roles_license
|
|
||||||
# - migrate_plus.migration.d7_simplenews_subscribers
|
|
||||||
# - migrate_plus.migration.d7_node_article
|
|
||||||
# - migrate_plus.migration.d7_simplenews_nodes
|
|
||||||
# - migrate_plus.migration.d7_node_materiau
|
|
||||||
# - migrate_plus.migration.d7_node_materiau_i18n
|
|
||||||
# - migrate_plus.migration.d7_node_article_i18n
|
|
||||||
# - migrate_plus.migration.d7_user_profile
|
|
||||||
# - migrate_plus.migration.d7_taxonomy_term_showroom
|
|
||||||
# - migrate_plus.migration.d7_taxonomy_term_tags_i18n
|
|
||||||
# - migrate_plus.migration.d7_taxonomy_term_tags
|
|
||||||
# - migrate_plus.migration.d7_taxonomy_term_thesaurus_i18n
|
|
||||||
# - migrate_plus.migration.d7_taxonomy_term_thesaurus
|
|
||||||
# - migrate_plus.migration.d7_flaglists
|
|
||||||
# - migrate_plus.migration.d7_flaglistitems
|
|
||||||
|
@ -5,6 +5,7 @@ namespace Drupal\popsu_migrate\Plugin\migrate\source;
|
|||||||
|
|
||||||
use Drupal\migrate\Row;
|
use Drupal\migrate\Row;
|
||||||
use Drush\Drush;
|
use Drush\Drush;
|
||||||
|
use Drupal\paragraphs\Entity\Paragraph;
|
||||||
|
|
||||||
// use Drupal\popsu_migrate\Plugin\migrate\source\D7Programme;
|
// use Drupal\popsu_migrate\Plugin\migrate\source\D7Programme;
|
||||||
|
|
||||||
@ -18,6 +19,22 @@ use Drush\Drush;
|
|||||||
*/
|
*/
|
||||||
class D7NodeProgramme extends D7Programme {
|
class D7NodeProgramme extends D7Programme {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function query() {
|
||||||
|
$query = parent::query($row);
|
||||||
|
|
||||||
|
// field_popsu_special_typetaxo 31 (Acueile)
|
||||||
|
$query->leftJoin('field_revision_field_popsu_special_typetaxo', 'ff', 'ff.revision_id = n.vid');
|
||||||
|
$query->fields('ff', [
|
||||||
|
'field_popsu_special_typetaxo_tid'
|
||||||
|
]);
|
||||||
|
$query->condition('ff.field_popsu_special_typetaxo_tid', 31);
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -48,14 +65,31 @@ class D7NodeProgramme extends D7Programme {
|
|||||||
$row->setSourceProperty('body', $body[0]['value']);
|
$row->setSourceProperty('body', $body[0]['value']);
|
||||||
$row->setSourceProperty('body_summary', $body[0]['summary']);
|
$row->setSourceProperty('body_summary', $body[0]['summary']);
|
||||||
|
|
||||||
// texts (migration_lookup)
|
|
||||||
$row->setSourceProperty('text_paragraphe_id', $nid);
|
|
||||||
|
|
||||||
// associateds
|
// associateds
|
||||||
$associateds = $this->getAssociatedSpecial($field_popsu_special_popsu_tid);
|
$associateds = $this->getAssociatedSpecial($field_popsu_special_popsu_tid);
|
||||||
Drush::output()->writeln(dump($associateds));
|
Drush::output()->writeln(dump($associateds));
|
||||||
|
|
||||||
|
// texts (migration_lookup)
|
||||||
|
$text = $row->getSourceProperty('field_popsu_special_text');
|
||||||
|
$text[0]['format'] = 'wysiwyg';
|
||||||
|
$p = Paragraph::create(['type' => 'textes']);
|
||||||
|
$p->set('field_texte', $text)
|
||||||
|
->set('field_titre', $row->getSourceProperty('title'))
|
||||||
|
->isNew();
|
||||||
|
$p->save();
|
||||||
|
|
||||||
|
$text_paragraphe = array(
|
||||||
|
array(
|
||||||
|
'target_id' => $p->id(),
|
||||||
|
'target_revision_id' => $p->getRevisionId(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$row->setSourceProperty('text_paragraphe', $text_paragraphe);
|
||||||
|
|
||||||
|
// Sous partie
|
||||||
|
|
||||||
// fichiers
|
// fichiers
|
||||||
|
// files from current node
|
||||||
$fichiers = array();
|
$fichiers = array();
|
||||||
foreach ($row->getSourceProperty('field_popsu_special_insert') as $value) {
|
foreach ($row->getSourceProperty('field_popsu_special_insert') as $value) {
|
||||||
$fichiers[] = $value;
|
$fichiers[] = $value;
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
// https://understanddrupal.com/articles/how-debug-drupal-migrations-part-2
|
|
||||||
|
|
||||||
namespace Drupal\popsu_migrate\Plugin\migrate\source;
|
|
||||||
|
|
||||||
use Drupal\migrate\Row;
|
|
||||||
use Drush\Drush;
|
|
||||||
|
|
||||||
// use Drupal\popsu_migrate\Plugin\migrate\source\D7Programme;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Drupal 7 node source from database.
|
|
||||||
*
|
|
||||||
* @MigrateSource(
|
|
||||||
* id = "d7_paragraphe_texts_programme",
|
|
||||||
* source_module = "node"
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
class D7PargrapheTextsProgramme extends D7Programme {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function prepareRow(Row $row) {
|
|
||||||
$nid = $row->getSourceProperty('nid');
|
|
||||||
$vid = $row->getSourceProperty('vid');
|
|
||||||
$type = $row->getSourceProperty('type');
|
|
||||||
|
|
||||||
// Get Field API field values.
|
|
||||||
foreach ($this->getFields('node', $type) as $field_name => $field) {
|
|
||||||
$row->setSourceProperty($field_name, $this->getFieldValues('node', $field_name, $nid, $vid, NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
// texts
|
|
||||||
$text = $row->getSourceProperty('field_popsu_special_text');
|
|
||||||
$row->setSourceProperty('text', $text[0]['value']);
|
|
||||||
$row->setSourceProperty('text_summary', $text[0]['summary']);
|
|
||||||
|
|
||||||
return parent::prepareRow($row);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -100,12 +100,12 @@ class D7Programme extends FieldableEntity {
|
|||||||
$query->condition('n.type', $this->configuration['node_type']);
|
$query->condition('n.type', $this->configuration['node_type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// field_popsu_special_typetaxo 31 (Acueile)
|
// // field_popsu_special_typetaxo 31 (Acueile)
|
||||||
$query->leftJoin('field_revision_field_popsu_special_typetaxo', 'ff', 'ff.revision_id = n.vid');
|
// $query->leftJoin('field_revision_field_popsu_special_typetaxo', 'ff', 'ff.revision_id = n.vid');
|
||||||
$query->fields('ff', [
|
// $query->fields('ff', [
|
||||||
'field_popsu_special_typetaxo_tid'
|
// 'field_popsu_special_typetaxo_tid'
|
||||||
]);
|
// ]);
|
||||||
$query->condition('ff.field_popsu_special_typetaxo_tid', 31);
|
// $query->condition('ff.field_popsu_special_typetaxo_tid', 31);
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user