popsu_migrate: D7NodeTheme textes paragraphes ok
This commit is contained in:
@@ -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