You are here

public function FieldInstance::query in Drupal 9

Same name in this branch
  1. 9 core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php \Drupal\field\Plugin\migrate\source\d6\FieldInstance::query()
  2. 9 core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php \Drupal\field\Plugin\migrate\source\d7\FieldInstance::query()
Same name and namespace in other branches
  1. 8 core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php \Drupal\field\Plugin\migrate\source\d7\FieldInstance::query()

Return value

\Drupal\Core\Database\Query\SelectInterface

Overrides SqlBase::query

File

core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php, line 58

Class

FieldInstance
Drupal 7 field instances source from database.

Namespace

Drupal\field\Plugin\migrate\source\d7

Code

public function query() {
  $query = $this
    ->select('field_config_instance', 'fci')
    ->fields('fci')
    ->fields('fc', [
    'type',
    'translatable',
  ])
    ->condition('fc.active', 1)
    ->condition('fc.storage_active', 1)
    ->condition('fc.deleted', 0)
    ->condition('fci.deleted', 0);
  $query
    ->join('field_config', 'fc', '[fci].[field_id] = [fc].[id]');

  // Optionally filter by entity type and bundle.
  if (isset($this->configuration['entity_type'])) {
    $query
      ->condition('fci.entity_type', $this->configuration['entity_type']);
    if (isset($this->configuration['bundle'])) {
      $query
        ->condition('fci.bundle', $this->configuration['bundle']);
    }
  }

  // The Title module fields are not migrated.
  if ($this
    ->moduleExists('title')) {
    $title_fields = [
      'title_field',
      'name_field',
      'description_field',
      'subject_field',
    ];
    $query
      ->condition('fc.field_name', $title_fields, 'NOT IN');
  }
  return $query;
}