class StubSourceGeneratorPlugin

Same name and namespace in other branches
  1. 11.x core/modules/migrate/tests/src/Unit/MigrateSourceTest.php \Drupal\Tests\migrate\Unit\StubSourceGeneratorPlugin

Defines a stubbed source plugin with a generator as iterator.

This stub overwrites the $skipCount, $cacheCounts, and $trackChanges properties.

Hierarchy

Expanded class hierarchy of StubSourceGeneratorPlugin

File

core/modules/migrate/tests/src/Unit/MigrateSourceTest.php, line 507

Namespace

Drupal\Tests\migrate\Unit
View source
class StubSourceGeneratorPlugin extends StubSourcePlugin {
  
  /**
   * {@inheritdoc}
   */
  protected $skipCount = TRUE;
  
  /**
   * {@inheritdoc}
   */
  protected $cacheCounts = TRUE;
  
  /**
   * {@inheritdoc}
   */
  protected $trackChanges = TRUE;
  
  /**
   * Return the skipCount value.
   */
  public function getSkipCount() {
    return $this->skipCount;
  }
  
  /**
   * Return the cacheCounts value.
   */
  public function getCacheCounts() {
    return $this->cacheCounts;
  }
  
  /**
   * Return the trackChanges value.
   */
  public function getTrackChanges() {
    return $this->trackChanges;
  }
  
  /**
   * {@inheritdoc}
   */
  protected function initializeIterator() {
    $data = [
      [
        'title' => 'foo',
      ],
      [
        'title' => 'bar',
      ],
      [
        'title' => 'iggy',
      ],
    ];
    foreach ($data as $row) {
      yield $row;
    }
  }

}

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