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'
|
||||
|
||||
# https://understanddrupal.com/articles/introduction-paragraphs-migrations-drupal
|
||||
pseudo_field_textes:
|
||||
plugin: migration_lookup
|
||||
migration: d7_paragraphe_texts_programme
|
||||
source: text_paragraphe_id
|
||||
field_textes:
|
||||
plugin: sub_process
|
||||
source:
|
||||
- '@pseudo_field_textes'
|
||||
process:
|
||||
target_id: '0'
|
||||
target_revision_id: '1'
|
||||
# pseudo_field_textes:
|
||||
# plugin: migration_lookup
|
||||
# migration: d7_paragraphe_texts_programme
|
||||
# source: text_paragraphe_id
|
||||
# field_textes:
|
||||
# plugin: sub_process
|
||||
# source:
|
||||
# - '@pseudo_field_textes'
|
||||
# process:
|
||||
# target_id: '0'
|
||||
# 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
|
||||
@ -75,4 +85,3 @@ migration_dependencies:
|
||||
required:
|
||||
- d7_allpublicfiles
|
||||
- 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: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
|
||||
config_devel:
|
||||
install:
|
||||
- migrate_plus.migration_group.d7_popsu
|
||||
- migrate_plus.migration.d7_allpublicfiles
|
||||
# config_devel:
|
||||
# install:
|
||||
# - migrate_plus.migration_group.d7_popsu
|
||||
# - migrate_plus.migration.d7_allpublicfiles
|
||||
# - migrate_plus.migration.d7_users
|
||||
# - migrate_plus.migration.d7_taxonomy_term_company
|
||||
# - 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
|
||||
# - migrate_plus.migration.d7_node_programme
|
||||
|
@ -5,6 +5,7 @@ namespace Drupal\popsu_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drush\Drush;
|
||||
use Drupal\paragraphs\Entity\Paragraph;
|
||||
|
||||
// use Drupal\popsu_migrate\Plugin\migrate\source\D7Programme;
|
||||
|
||||
@ -18,6 +19,22 @@ use Drush\Drush;
|
||||
*/
|
||||
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}
|
||||
*/
|
||||
@ -48,14 +65,31 @@ class D7NodeProgramme extends D7Programme {
|
||||
$row->setSourceProperty('body', $body[0]['value']);
|
||||
$row->setSourceProperty('body_summary', $body[0]['summary']);
|
||||
|
||||
// texts (migration_lookup)
|
||||
$row->setSourceProperty('text_paragraphe_id', $nid);
|
||||
|
||||
// associateds
|
||||
$associateds = $this->getAssociatedSpecial($field_popsu_special_popsu_tid);
|
||||
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
|
||||
// files from current node
|
||||
$fichiers = array();
|
||||
foreach ($row->getSourceProperty('field_popsu_special_insert') as $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']);
|
||||
}
|
||||
|
||||
// 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);
|
||||
// // 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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user