popsu_migrate: D7NodeProjet textes ok
This commit is contained in:
@@ -89,6 +89,8 @@ process:
|
||||
alt: alt
|
||||
title: title
|
||||
|
||||
field_textes: field_textes
|
||||
|
||||
field_memo: field_memo
|
||||
|
||||
migration_dependencies:
|
||||
|
@@ -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(
|
||||
|
Reference in New Issue
Block a user