You are here

public function FileEntityItem::prepareRow in Media Migration 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/FileEntityItem.php, line 126

Class

FileEntityItem
File Entity Item source plugin.

Namespace

Drupal\media_migration\Plugin\migrate\source\d7

Code

public function prepareRow(Row $row) {
  [
    'type' => $type,
    'scheme' => $scheme,
  ] = $row
    ->getSource();
  if (!($dealer_plugin = $this->fileEntityDealerManager
    ->createInstanceFromTypeAndScheme($type, $scheme))) {
    return FALSE;
  }

  // Get Field API field values.
  $fields = $this
    ->getFields('file', $type);
  $file_id = $row
    ->getSourceProperty('fid');
  foreach (array_keys($fields) as $field_name) {
    $row
      ->setSourceProperty($field_name, $this
      ->getFieldValues('file', $field_name, $file_id));
  }
  $row
    ->setSourceProperty('bundle', $dealer_plugin
    ->getDestinationMediaTypeId());
  $dealer_plugin
    ->prepareMediaEntityRow($row, $this
    ->getDatabase());
  return parent::prepareRow($row);
}