You are here

trait DummyQueryTrait in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/migrate/src/Plugin/migrate/source/DummyQueryTrait.php \Drupal\migrate\Plugin\migrate\source\DummyQueryTrait

Trait providing a dummy select query object for source plugins based on SqlBase which override initializeIterator() to obtain their data from other SqlBase services instead of a direct query. This ensures that query() returns a valid object, even though it isn't used for iteration.

Hierarchy

3 files declare their use of DummyQueryTrait
CommentVariable.php in core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php
Contains \Drupal\comment\Plugin\migrate\source\d6\CommentVariable.
UploadInstance.php in core/modules/file/src/Plugin/migrate/source/d6/UploadInstance.php
Contains \Drupal\file\Plugin\migrate\source\d6\UploadInstance.
UserPictureInstance.php in core/modules/user/src/Plugin/migrate/source/UserPictureInstance.php
Contains \Drupal\user\Plugin\migrate\source\UserPictureInstance.

File

core/modules/migrate/src/Plugin/migrate/source/DummyQueryTrait.php, line 16
Contains \Drupal\migrate\Plugin\migrate\source\DummyQueryTrait.

Namespace

Drupal\migrate\Plugin\migrate\source
View source
trait DummyQueryTrait {

  /**
   * {@inheritdoc}
   */
  public function query() {

    // Pass an arbritrary table name - the query should never be executed anyway.
    $query = $this
      ->select(uniqid(), 's')
      ->range(0, 1);
    $query
      ->addExpression('1');
    return $query;
  }

  /**
   * {@inheritdoc}
   */
  public function count() {
    return 1;
  }

}

Members