获取用于迁移的段落包(paragraphs_item)值

时间:2019-01-31 17:14:07

标签: drupal-7 bundle drupal-8 paragraph

我正在将节点从D7迁移到D8,但是我需要获取段落主体值并将其与主体值连接起来。这是该节点的转储:

object(Drupal\migrate\Row)#1848 (8) {
 ["source":protected]=>
   array(58) {
   ["nid"]=>
      string(6) "657783"
   ["type"]=>
      string(4) "blog"
   ["field_paragraph_body"]=>
array(4) {
  [0]=>
  array(2) {
    ["value"]=>
    string(1) "1"
    ["revision_id"]=>
    string(2) "61"
  }
  [1]=>
  array(2) {
    ["value"]=>
    string(1) "6"
    ["revision_id"]=>
    string(2) "66"
  }
  [2]=>
  array(2) {
    ["value"]=>
    string(2) "11"
    ["revision_id"]=>
    string(2) "71"
  }
  [3]=>
  array(2) {
    ["value"]=>
    string(2) "16"
    ["revision_id"]=>
    string(2) "76"
  }
}
["field_body"]=>
   array(1) {
     [0]=>
   array(2) {
     ["value"]=>
       string(7381) " Quisque velit nisi, pretium ut lacinia in, elementum id enim. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus. Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Donec rutrum congue leo eget malesuada. Donec rutrum congue leo eget malesuada. Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Nulla porttitor accumsan tincidunt. Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Curabitur non nulla sit amet nisl tempus convallis quis ac lectus. Cras ultricies ligula sed magna dictum porta. "
      ["format"]=>
       string(9) "full_html"
   }
  }
 }
}   

我正在尝试从我编写的D8迁移插件中获取值。以下是相关代码:

class MmNodeBlogParagraphToBody extends ProcessPluginBase  {

  /**
 * {@inheritdoc}
 */
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    $node = \Drupal::entityTypeManager()->getStorage('node')->load($nid);
    var_dump($node);
    $body = $row->getSourceProperty("field_body")[0]["value"];
    var_dump($body);
    $para_body[] = $row->getSourceProperty("field_paragraph_body")[0];
    $pbody = (int)$para_body[0]['value'];
    var_dump("value : " . (int)$para_body[0]['value']);  //string(9) "value : 1"
    var_dump("revision_id : " . (int)$para_body[0]['revision_id']);   //string(16) "revision_id : 61"
    $entities = entity_load('paragraph', array(), array($pbody), $reset = FALSE);
    var_dump("entities : " .$entities);   //string(11) "entities : "
    $entitiesrev = entity_load('paragraph', array(), array( (int)$para_body[0]['revision_id']), $reset = FALSE);
    var_dump("entitiesrev : " .$entitiesrev);  //"entitiesrev : "
}
} 

以下是与段落表相关的表:

paragraphs_item table

field_data_field_paragraph_image_right_url表
   image_right_url table

field_data_field_paragraph_text_right表
  text_right

field_data_field_paragraph_text
  paragraph_text

但是值是空的!为什么?
我有几捆:
-image_1colleft_text_1colright
-text_1col
-text_1colleft_text_1colright
-text_1colleft_image_1colright

如何获取这些段落项目/捆绑商品的值?

0 个答案:

没有答案