public function importParagraphs(array $paragraphs) {

    $data = $this->loadDataArray('paragraph');
    $paragraph_items = [];
    $uuids = [];

    foreach ($paragraphs as $k => $paragraph_data) {
      $item = $data[$paragraph_data];
      if (!empty($item)) {

        // Prepare content.
        $values = [
          'type' => $item['type'],
        ];

        if (!empty($item['field_body'])) {
          $body = $this->getBodyData($item['field_body']);
          if ($body !== FALSE) {
            $values['field_body'] = [
              'value' => $body,
              'format' => 'rich_text',
            ];
          }
        }

        if (!empty($item['field_title'])) {
          $values['field_title'] = $item['field_title'];
        }

        if (!empty($item['field_heading'])) {
          $values['field_heading'] = $item['field_heading'];
        }

        $this->loadProcessorPlugins($values, $item, 'paragraph');

        // Set author.
        $values['uid'] = 1;

        // Create Media.
        $entity = $this->entityTypeManager->getStorage('paragraph')->create($values);
        $entity->save();
        $uuids[$entity->uuid()] = 'paragraph';
        $paragraph_items[] = $entity;
      }
    }

    $this->storeCreatedContentUuids($uuids);

    return $paragraph_items;
  }
public function importParagraphs(array $paragraphs) {

    $data = $this->loadDataArray('paragraph');
    $paragraph_items = [];
    $uuids = [];

    foreach ($paragraphs as $k => $paragraph_data) {
      $item = $data[$paragraph_data];
      if (!empty($item)) {

        // Prepare content.
        $values = [
          'type' => $item['type'],
        ];

        if (!empty($item['field_body'])) {
          $body = $this->getBodyData($item['field_body']);
          if ($body !== FALSE) {
            $values['field_body'] = [
              'value' => $body,
              'format' => 'rich_text',
            ];
          }
        }

        if (!empty($item['field_title'])) {
          $values['field_title'] = $item['field_title'];
        }

        if (!empty($item['field_heading'])) {
          $values['field_heading'] = $item['field_heading'];
        }

        $this->loadProcessorPlugins($values, $item, 'paragraph');

        // Set author.
        $values['uid'] = 1;

        // Create Media.
        $entity = $this->entityTypeManager->getStorage('paragraph')->create($values);
        $entity->save();
        $uuids[$entity->uuid()] = 'paragraph';
        $paragraph_items[] = $entity;
      }
    }

    $this->storeCreatedContentUuids($uuids);

    return $paragraph_items;
  }
public function importParagraphs ( array $ paragraphs ) { $ data = $ this -> loadDataArray ( 'paragraph' ) ; $ paragraph_items = [ ] ; $ uuids = [ ] ; foreach ( $ paragraphs as $ k => $ paragraph_data ) { $ item = $ data [ $ paragraph_data ] ; if ( ! empty ( $ item ) ) { // Prepare content. $ values = [ 'type' => $ item [ 'type' ] , ] ; if ( ! empty ( $ item [ 'field_body' ] ) ) { $ body = $ this -> getBodyData ( $ item [ 'field_body' ] ) ; if ( $ body !== FALSE ) { $ values [ 'field_body' ] = [ 'value' => $ body , 'format' => 'rich_text' , ] ; } } if ( ! empty ( $ item [ 'field_title' ] ) ) { $ values [ 'field_title' ] = $ item [ 'field_title' ] ; } if ( ! empty ( $ item [ 'field_heading' ] ) ) { $ values [ 'field_heading' ] = $ item [ 'field_heading' ] ; } $ this -> loadProcessorPlugins ( $ values , $ item , 'paragraph' ) ; // Set author. $ values [ 'uid' ] = 1 ; // Create Media. $ entity = $ this -> entityTypeManager -> getStorage ( 'paragraph' ) -> create ( $ values ) ; $ entity -> save ( ) ; $ uuids [ $ entity -> uuid ( ) ] = 'paragraph' ; $ paragraph_items [ ] = $ entity ; } } $ this -> storeCreatedContentUuids ( $ uuids ) ; return $ paragraph_items ; }
Import paragraphs.
Import paragraphs .