You are here

public function SourcePluginBase::prepareRow in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php \Drupal\migrate\Plugin\migrate\source\SourcePluginBase::prepareRow()
  2. 9 core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php \Drupal\migrate\Plugin\migrate\source\SourcePluginBase::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 MigrateSourceInterface::prepareRow

21 calls to SourcePluginBase::prepareRow()
Action::prepareRow in core/modules/system/src/Plugin/migrate/source/Action.php
Adds additional data to the row.
Block::prepareRow in core/modules/block/src/Plugin/migrate/source/Block.php
Adds additional data to the row.
BlockTranslation::prepareRow in core/modules/block/src/Plugin/migrate/source/d6/BlockTranslation.php
Adds additional data to the row.
CommentType::prepareRow in core/modules/comment/src/Plugin/migrate/source/CommentType.php
Adds additional data to the row.
ContactCategory::prepareRow in core/modules/contact/src/Plugin/migrate/source/ContactCategory.php
Adds additional data to the row.

... See full list

50 methods override SourcePluginBase::prepareRow()
Action::prepareRow in core/modules/system/src/Plugin/migrate/source/Action.php
Adds additional data to the row.
Block::prepareRow in core/modules/block/src/Plugin/migrate/source/Block.php
Adds additional data to the row.
BlockCustomTranslation::prepareRow in core/modules/block_content/src/Plugin/migrate/source/d7/BlockCustomTranslation.php
Adds additional data to the row.
Comment::prepareRow in core/modules/comment/src/Plugin/migrate/source/d6/Comment.php
Adds additional data to the row.
Comment::prepareRow in core/modules/comment/src/Plugin/migrate/source/d7/Comment.php
Adds additional data to the row.

... See full list

File

core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php, line 292

Class

SourcePluginBase
The base class for source plugins.

Namespace

Drupal\migrate\Plugin\migrate\source

Code

public function prepareRow(Row $row) {
  $result = TRUE;
  try {
    $result_hook = $this
      ->getModuleHandler()
      ->invokeAll('migrate_prepare_row', [
      $row,
      $this,
      $this->migration,
    ]);
    $result_named_hook = $this
      ->getModuleHandler()
      ->invokeAll('migrate_' . $this->migration
      ->id() . '_prepare_row', [
      $row,
      $this,
      $this->migration,
    ]);

    // We will skip if any hook returned FALSE.
    $skip = $result_hook && in_array(FALSE, $result_hook) || $result_named_hook && in_array(FALSE, $result_named_hook);
    $save_to_map = TRUE;
  } catch (MigrateSkipRowException $e) {
    $skip = TRUE;
    $save_to_map = $e
      ->getSaveToMap();
    if ($message = trim($e
      ->getMessage())) {
      $this->idMap
        ->saveMessage($row
        ->getSourceIdValues(), $message, MigrationInterface::MESSAGE_INFORMATIONAL);
    }
  }

  // We're explicitly skipping this row - keep track in the map table.
  if ($skip) {

    // Make sure we replace any previous messages for this item with any
    // new ones.
    if ($save_to_map) {
      $this->idMap
        ->saveIdMapping($row, [], MigrateIdMapInterface::STATUS_IGNORED);
      $this->currentRow = NULL;
      $this->currentSourceIds = NULL;
    }
    $result = FALSE;
  }
  elseif ($this->trackChanges) {

    // When tracking changed data, We want to quietly skip (rather than
    // "ignore") rows with changes. The caller needs to make that decision,
    // so we need to provide them with the necessary information (before and
    // after hashes).
    $row
      ->rehash();
  }
  return $result;
}