popsu_migrate: D7NodeProjet textes ok

This commit is contained in:
2021-04-20 10:51:58 +02:00
parent 3db2e683b7
commit 33131889dc
10 changed files with 40 additions and 9 deletions

View File

@@ -89,6 +89,8 @@ process:
alt: alt
title: title
field_textes: field_textes
field_memo: field_memo
migration_dependencies:

View File

@@ -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;
@@ -113,6 +114,7 @@ class D7NodeProjet extends FieldableEntity {
$memo = '';
$memo .= "#migration : old nid = ".$nid."\n";
$memo .= "#migration : old content type = ".$type."\n";
// Get Field API field values.
foreach ($this->getFields('node', $type) as $field_name => $field) {
@@ -276,6 +278,32 @@ class D7NodeProjet extends FieldableEntity {
$row->setSourceProperty('diaporama', $field_diaporama);
}
# Text paragraphe
$text_fields = array(
'field_popsu_projet_methodo' => 'Démarche & méthodologie',
'field_popsu_projet_demarche' => 'Chronologie',
'field_popsu_projet_programme' => 'Programme',
);
$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);
}
// record migration errors in field_memo
if(isset($memo)){
$field_memo = array(