You are here

public function FieldCollectionItem::prepareRow in Paragraphs 8

Adds additional data to the row.

Parameters

\Drupal\migrate\Row $row: The row object.

Return value

bool FALSE if this row needs to be skipped.

Overrides SourcePluginBase::prepareRow

File

src/Plugin/migrate/source/d7/FieldCollectionItem.php, line 63

Class

FieldCollectionItem
Field Collection Item source plugin.

Namespace

Drupal\paragraphs\Plugin\migrate\source\d7

Code

public function prepareRow(Row $row) {

  // Remove field_ prefix for new bundle.
  $bundle = $row
    ->getSourceProperty('field_name');
  $bundle = substr($bundle, FieldCollection::FIELD_COLLECTION_PREFIX_LENGTH);
  $row
    ->setSourceProperty('bundle', $bundle);

  // Get Field API field values.
  $field_names = array_keys($this
    ->getFields('field_collection_item', $row
    ->getSourceProperty('field_name')));
  $item_id = $row
    ->getSourceProperty('item_id');
  $revision_id = $row
    ->getSourceProperty('revision_id');
  foreach ($field_names as $field_name) {
    $value = $this
      ->getFieldValues('field_collection_item', $field_name, $item_id, $revision_id);
    $row
      ->setSourceProperty($field_name, $value);
  }
  return parent::prepareRow($row);
}