popsu_migrate: D7NodeProgramme partenaire paragraphe ok
This commit is contained in:
parent
85b5fcff6e
commit
e8040aa7b9
@ -64,6 +64,8 @@ process:
|
||||
|
||||
field_sous_parties: sous_parties
|
||||
|
||||
field_partenaires: partenaires
|
||||
|
||||
field_fichier:
|
||||
plugin: sub_process
|
||||
source: fichiers
|
||||
|
@ -42,12 +42,11 @@ class D7NodeProgramme extends D7Programme {
|
||||
$nid = $row->getSourceProperty('nid');
|
||||
$vid = $row->getSourceProperty('vid');
|
||||
$type = $row->getSourceProperty('type');
|
||||
$title = $row->getSourceProperty('title');
|
||||
Drush::output()->writeln('- - - - ' . $title . '- - - - ');
|
||||
|
||||
// Get Field API field values.
|
||||
foreach ($this->getFields('node', $type) as $field_name => $field) {
|
||||
// Ensure we're using the right language if the entity and the field are
|
||||
// translatable.
|
||||
// $field_language = $entity_translatable && $field['translatable'] ? $language : NULL;
|
||||
$row->setSourceProperty($field_name, $this->getFieldValues('node', $field_name, $nid, $vid, NULL));
|
||||
}
|
||||
|
||||
@ -67,9 +66,9 @@ class D7NodeProgramme extends D7Programme {
|
||||
|
||||
// associateds
|
||||
$associateds = $this->getAssociatedSpecial($field_popsu_special_popsu_tid);
|
||||
Drush::output()->writeln(dump($associateds));
|
||||
// Drush::output()->writeln(dump($associateds));
|
||||
|
||||
// texts (migration_lookup)
|
||||
// texts (paragraphe)
|
||||
$text = $row->getSourceProperty('field_popsu_special_text');
|
||||
$text[0]['format'] = 'wysiwyg';
|
||||
$p = Paragraph::create(['type' => 'textes']);
|
||||
@ -129,6 +128,73 @@ class D7NodeProgramme extends D7Programme {
|
||||
$row->setSourceProperty('sous_parties', $sous_parties);
|
||||
}
|
||||
|
||||
// Partenaires
|
||||
$ps = array();
|
||||
// looping through nodes
|
||||
foreach ($associateds['partenaires'] as $key => $special) {
|
||||
$p = Paragraph::create(['type' => 'partenaires']);
|
||||
$p->set('field_nom_partenaire', $special['title']);
|
||||
// texts
|
||||
if(!empty($special['field_popsu_special_body']) || !empty($special['field_popsu_special_text'])){
|
||||
$text = array(
|
||||
array(
|
||||
'value' => '',
|
||||
'summary' => '',
|
||||
'format' => 'wysiwyg'
|
||||
),
|
||||
);
|
||||
foreach (['field_popsu_special_body', 'field_popsu_special_text'] as $src_field) {
|
||||
if (!empty($special[$src_field])) {
|
||||
$text[0]['value'] .= $special[$src_field][0]['value'];
|
||||
$text[0]['summary'] .= isset($special[$src_field][0]['summary']) ? $special[$src_field][0]['summary'] : '';
|
||||
}
|
||||
}
|
||||
$p->set('field_presentation', $text);
|
||||
}
|
||||
// files
|
||||
// 'field_fichiers' => ['field_popsu_special_insert_intro', 'field_popsu_special_insert'],
|
||||
$files = array();
|
||||
foreach (['field_popsu_special_insert_intro', 'field_popsu_special_insert'] as $field) {
|
||||
if (!empty($special[$field])) {
|
||||
// Drush::output()->writeln(dump($special[$field]));
|
||||
foreach ($special[$field] as $file) {
|
||||
// Drush::output()->writeln(dump($file));
|
||||
// change file fid from migration lookup
|
||||
$database = \Drupal::database();
|
||||
$fidquery = $database->select('migrate_map_d7_allpublicfiles', 'm')
|
||||
->condition('m.sourceid1', $file['fid'])
|
||||
->fields('m', ['sourceid1', 'destid1']);
|
||||
$result = $fidquery->execute();
|
||||
foreach ($result as $record) {
|
||||
if($record){
|
||||
$dfid = $record->destid1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($dfid) {
|
||||
$file['target_id'] = $dfid;
|
||||
unset($file['fid']);
|
||||
$files[] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($files)) {
|
||||
Drush::output()->writeln(dump($files));
|
||||
$p->set('field_fichiers', $files);
|
||||
}
|
||||
|
||||
$p->isNew();
|
||||
$p->save();
|
||||
$ps[] = array(
|
||||
'target_id' => $p->id(),
|
||||
'target_revision_id' => $p->getRevisionId(),
|
||||
);
|
||||
}
|
||||
if (!empty($ps)) {
|
||||
$row->setSourceProperty('partenaires', $ps);
|
||||
}
|
||||
|
||||
// fichiers
|
||||
// files from current node
|
||||
$fichiers = array();
|
||||
|
Loading…
x
Reference in New Issue
Block a user