function SourcePluginBase::next

Same name and namespace in other branches
  1. 8.9.x core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php \Drupal\migrate\Plugin\migrate\source\SourcePluginBase::next()
  2. 10 core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php \Drupal\migrate\Plugin\migrate\source\SourcePluginBase::next()
  3. 11.x core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php \Drupal\migrate\Plugin\migrate\source\SourcePluginBase::next()
1 call to SourcePluginBase::next()
SourcePluginBase::rewind in core/modules/migrate/src/Plugin/migrate/source/SourcePluginBase.php
Rewinds the iterator.

File

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

Class

SourcePluginBase
The base class for source plugins.

Namespace

Drupal\migrate\Plugin\migrate\source

Code

public function next() {
    $this->currentSourceIds = NULL;
    $this->currentRow = NULL;
    // In order to find the next row we want to process, we ask the source
    // plugin for the next possible row.
    while (!isset($this->currentRow) && $this->getIterator()
        ->valid()) {
        $row_data = $this->getIterator()
            ->current() + $this->configuration;
        $this->fetchNextRow();
        $row = new Row($row_data, $this->getIds());
        // Populate the source key for this row.
        $this->currentSourceIds = $row->getSourceIdValues();
        // Pick up the existing map row, if any, unless fetchNextRow() did it.
        if (!$this->mapRowAdded && ($id_map = $this->idMap
            ->getRowBySource($this->currentSourceIds))) {
            $row->setIdMap($id_map);
        }
        // Clear any previous messages for this row before potentially adding
        // new ones.
        if (!empty($this->currentSourceIds)) {
            $this->idMap
                ->delete($this->currentSourceIds, TRUE);
        }
        // Preparing the row gives source plugins the chance to skip.
        if ($this->prepareRow($row) === FALSE) {
            continue;
        }
        // Check whether the row needs processing.
        // 1. This row has not been imported yet.
        // 2. Explicitly set to update.
        // 3. The row is newer than the current high-water mark.
        // 4. If no such property exists then try by checking the hash of the row.
        if (!$row->getIdMap() || $row->needsUpdate() || $this->aboveHighWater($row) || $this->rowChanged($row)) {
            $this->currentRow = $row->freezeSource();
        }
        if ($this->getHighWaterProperty()) {
            $this->saveHighWater($row->getSourceProperty($this->highWaterProperty['name']));
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.