function FieldInstance::query

Same name in this branch
  1. 11.x core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php \Drupal\field\Plugin\migrate\source\d6\FieldInstance::query()
Same name in other branches
  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()
  3. 8.9.x core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php \Drupal\field\Plugin\migrate\source\d6\FieldInstance::query()
  4. 8.9.x core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php \Drupal\field\Plugin\migrate\source\d7\FieldInstance::query()
  5. 10 core/modules/field/src/Plugin/migrate/source/d6/FieldInstance.php \Drupal\field\Plugin\migrate\source\d6\FieldInstance::query()
  6. 10 core/modules/field/src/Plugin/migrate/source/d7/FieldInstance.php \Drupal\field\Plugin\migrate\source\d7\FieldInstance::query()

Overrides SqlBase::query

File

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

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;
}

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