You are here

public function SourceFilter::accept in Migrate Tools 8.5

Same name and namespace in other branches
  1. 8.4 src/SourceFilter.php \Drupal\migrate_tools\SourceFilter::accept()

File

src/SourceFilter.php, line 36

Class

SourceFilter
Class to filter source by an ID list.

Namespace

Drupal\migrate_tools

Code

public function accept() {

  // No idlist filtering, don't filter.
  if (empty($this->idList)) {
    return TRUE;
  }

  // Some source plugins do not extend SourcePluginBase. These cannot be
  // filtered so warn and return all values.
  if (!$this
    ->getInnerIterator() instanceof SourcePluginBase) {
    trigger_error(sprintf('The source plugin %s is not an instance of %s. Extend from %s to support idlist filtering.', $this
      ->getInnerIterator()
      ->getPluginId(), SourcePluginBase::class, SourcePluginBase::class));
    return TRUE;
  }

  // Row is included.
  if (in_array(array_values($this
    ->getInnerIterator()
    ->getCurrentIds()), $this->idList)) {
    return TRUE;
  }
}