"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.10/core/modules/field/src/Plugin/migrate/source/d7/FieldOptionTranslation.php" (26 Nov 2020, 2171 Bytes) of package /linux/www/drupal-8.9.10.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "FieldOptionTranslation.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Drupal\field\Plugin\migrate\source\d7;
    4 
    5 /**
    6  * Gets field option label translations.
    7  *
    8  * @MigrateSource(
    9  *   id = "d7_field_option_translation",
   10  *   source_module = "i18n_field"
   11  * )
   12  */
   13 class FieldOptionTranslation extends Field {
   14 
   15   /**
   16    * {@inheritdoc}
   17    */
   18   public function query() {
   19     $query = parent::query();
   20     $query->leftJoin('i18n_string', 'i18n', 'i18n.type = fc.field_name');
   21     $query->innerJoin('locales_target', 'lt', 'lt.lid = i18n.lid');
   22     $query->condition('i18n.textgroup', 'field')
   23       ->condition('objectid', '#allowed_values');
   24     // Add all i18n and locales_target fields.
   25     $query
   26       ->fields('i18n', [
   27         // All table fields except lid and type.
   28         'textgroup',
   29         'context',
   30         'objectid',
   31         'property',
   32         'objectindex',
   33         'format',
   34       ])
   35       ->fields('lt');
   36     $query->addField('fci', 'bundle');
   37     $query->addField('i18n', 'lid', 'i18n_lid');
   38     $query->addField('i18n', 'type', 'i18n_type');
   39     $query->orderBy('i18n.lid');
   40 
   41     return $query;
   42   }
   43 
   44   /**
   45    * {@inheritdoc}
   46    */
   47   public function fields() {
   48     $fields = [
   49       'bundle' => $this->t('Entity bundle'),
   50       'lid' => $this->t('Source string ID'),
   51       'textgroup' => $this->t('A module defined group of translations'),
   52       'context' => $this->t('Full string ID'),
   53       'objectid' => $this->t('Object ID'),
   54       'property' => $this->t('Object property for this string'),
   55       'objectindex' => $this->t('Integer value of Object ID'),
   56       'format' => $this->t('The input format used by this string'),
   57       'translation' => $this->t('Translation of the option'),
   58       'language' => $this->t('Language code'),
   59       'plid' => $this->t('Parent lid'),
   60       'plural' => $this->t('Plural index number in case of plural strings'),
   61       'i18n_status' => $this->t('A boolean indicating whether this translation needs to be updated'),
   62     ];
   63     return parent::fields() + $fields;
   64   }
   65 
   66   /**
   67    * {@inheritdoc}
   68    */
   69   public function getIds() {
   70     return parent::getIds() +
   71       [
   72         'language' => ['type' => 'string'],
   73         'property' => ['type' => 'string'],
   74       ];
   75   }
   76 
   77 }