You are here

public function BeerNode::prepareRow in Migrate Plus 8.5

Same name and namespace in other branches
  1. 8 migrate_example/src/Plugin/migrate/source/BeerNode.php \Drupal\migrate_example\Plugin\migrate\source\BeerNode::prepareRow()
  2. 8.2 migrate_example/src/Plugin/migrate/source/BeerNode.php \Drupal\migrate_example\Plugin\migrate\source\BeerNode::prepareRow()
  3. 8.3 migrate_example/src/Plugin/migrate/source/BeerNode.php \Drupal\migrate_example\Plugin\migrate\source\BeerNode::prepareRow()
  4. 8.4 migrate_example/src/Plugin/migrate/source/BeerNode.php \Drupal\migrate_example\Plugin\migrate\source\BeerNode::prepareRow()

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

migrate_example/src/Plugin/migrate/source/BeerNode.php, line 86

Class

BeerNode
Source plugin for beer content.

Namespace

Drupal\migrate_example\Plugin\migrate\source

Code

public function prepareRow(Row $row) {

  // As explained above, we need to pull the style relationships into our
  // source row here, as an array of 'style' values (the unique ID for
  // the beer_term migration).
  $terms = $this
    ->select('migrate_example_beer_topic_node', 'bt')
    ->fields('bt', [
    'style',
  ])
    ->condition('bid', $row
    ->getSourceProperty('bid'))
    ->execute()
    ->fetchCol();
  $row
    ->setSourceProperty('terms', $terms);

  // As we did for favorite beers in the user migration, we need to explode
  // the multi-value country names.
  if ($value = $row
    ->getSourceProperty('countries')) {
    $row
      ->setSourceProperty('countries', explode('|', $value));
  }
  return parent::prepareRow($row);
}