Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

DummyQueryTrait.php

Namespace

Drupal\migrate\Plugin\migrate\source

File

core/modules/migrate/src/Plugin/migrate/source/DummyQueryTrait.php

View source
<?php

namespace Drupal\migrate\Plugin\migrate\source;


/**
 * Provides a dummy select query object for source plugins.
 *
 * 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 is not used for iteration.
 */
trait DummyQueryTrait {
    
    /**
     * {@inheritdoc}
     */
    public function query() {
        // Pass an arbitrary table name - the query should never be executed
        // anyway.
        $query = $this->select(uniqid(), 's')
            ->range(0, 1);
        $query->addExpression('1');
        return $query;
    }
    
    /**
     * {@inheritdoc}
     */
    protected function doCount() {
        return 1;
    }

}

Traits

Title Deprecated Summary
DummyQueryTrait Provides a dummy select query object for source plugins.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal