function FieldOptionTranslation::query

Same name in this branch
  1. 8.9.x core/modules/field/src/Plugin/migrate/source/d7/FieldOptionTranslation.php \Drupal\field\Plugin\migrate\source\d7\FieldOptionTranslation::query()
Same name in other branches
  1. 9 core/modules/field/src/Plugin/migrate/source/d6/FieldOptionTranslation.php \Drupal\field\Plugin\migrate\source\d6\FieldOptionTranslation::query()
  2. 9 core/modules/field/src/Plugin/migrate/source/d7/FieldOptionTranslation.php \Drupal\field\Plugin\migrate\source\d7\FieldOptionTranslation::query()
  3. 10 core/modules/field/src/Plugin/migrate/source/d6/FieldOptionTranslation.php \Drupal\field\Plugin\migrate\source\d6\FieldOptionTranslation::query()
  4. 10 core/modules/field/src/Plugin/migrate/source/d7/FieldOptionTranslation.php \Drupal\field\Plugin\migrate\source\d7\FieldOptionTranslation::query()
  5. 11.x core/modules/field/src/Plugin/migrate/source/d6/FieldOptionTranslation.php \Drupal\field\Plugin\migrate\source\d6\FieldOptionTranslation::query()
  6. 11.x core/modules/field/src/Plugin/migrate/source/d7/FieldOptionTranslation.php \Drupal\field\Plugin\migrate\source\d7\FieldOptionTranslation::query()

Overrides Field::query

1 call to FieldOptionTranslation::query()
FieldInstanceOptionTranslation::query in core/modules/field/src/Plugin/migrate/source/d6/FieldInstanceOptionTranslation.php
1 method overrides FieldOptionTranslation::query()
FieldInstanceOptionTranslation::query in core/modules/field/src/Plugin/migrate/source/d6/FieldInstanceOptionTranslation.php

File

core/modules/field/src/Plugin/migrate/source/d6/FieldOptionTranslation.php, line 18

Class

FieldOptionTranslation
Gets field option label translations.

Namespace

Drupal\field\Plugin\migrate\source\d6

Code

public function query() {
    // Get the fields that have field options translations.
    $query = $this->select('i18n_strings', 'i18n')
        ->fields('i18n')
        ->fields('lt', [
        'translation',
        'language',
        'plid',
        'plural',
    ])
        ->condition('i18n.type', 'field')
        ->condition('property', 'option\\_%', 'LIKE');
    $query->innerJoin('locales_target', 'lt', 'lt.lid = i18n.lid');
    $query->leftjoin('content_node_field', 'cnf', 'cnf.field_name = i18n.objectid');
    $query->addField('cnf', 'field_name');
    $query->addField('cnf', 'global_settings');
    // Minimise changes to the d6_field_option_translation.yml, which is copied
    // from d6_field.yml, by ensuring the 'type' property is from
    // content_node_field table.
    $query->addField('cnf', 'type');
    $query->addField('i18n', 'type', 'i18n_type');
    // The i18n_string module adds a status column to locale_target. It was
    // originally 'status' in a later revision it was named 'i18n_status'.
    
    /** @var \Drupal\Core\Database\Schema $db */
    if ($this->getDatabase()
        ->schema()
        ->fieldExists('locales_target', 'status')) {
        $query->addField('lt', 'status', 'i18n_status');
    }
    if ($this->getDatabase()
        ->schema()
        ->fieldExists('locales_target', 'i18n_status')) {
        $query->addField('lt', 'i18n_status');
    }
    return $query;
}

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