public function FieldCollectionType::prepareRow

File

paragraphs/src/Plugin/migrate/source/d7/FieldCollectionType.php, line 46

Class

FieldCollectionType
Field Collection Type source plugin.

Namespace

Drupal\paragraphs\Plugin\migrate\source\d7

Code

public function prepareRow(Row $row) {
  $name = $row
    ->getSourceProperty('field_name');

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

  // Field collections don't have descriptions, optionally add one.
  if ($this->configuration['add_description']) {
    $row
      ->setSourceProperty('description', 'Migrated from field_collection ' . $name);
  }
  else {
    $row
      ->setSourceProperty('description', '');
  }

  // Set label from bundle because we don't have a label in D7 field
  // collections.
  $row
    ->setSourceProperty('name', ucfirst(preg_replace('/_/', ' ', $bundle)));
  return parent::prepareRow($row);
}