VocabularyTranslation.php in Drupal 10
File
core/modules/taxonomy/src/Plugin/migrate/source/d6/VocabularyTranslation.php
View source
<?php
namespace Drupal\taxonomy\Plugin\migrate\source\d6;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
class VocabularyTranslation extends DrupalSqlBase {
public function query() {
$query = $this
->select('vocabulary', 'v')
->fields('v')
->fields('i18n', [
'lid',
'type',
'property',
'objectid',
])
->fields('lt', [
'lid',
'translation',
])
->condition('i18n.type', 'vocabulary');
$query
->addField('lt', 'language', 'lt.language');
$query
->join('i18n_strings', 'i18n', '[v].[vid] = [i18n].[objectindex]');
$query
->innerJoin('locales_target', 'lt', '[lt].[lid] = [i18n].[lid]');
return $query;
}
public function fields() {
return [
'vid' => $this
->t('The vocabulary ID.'),
'language' => $this
->t('Language for this field.'),
'property' => $this
->t('Name of property being translated.'),
'translation' => $this
->t('Translation of either the title or explanation.'),
];
}
public function prepareRow(Row $row) {
$language = $row
->getSourceProperty('ltlanguage');
$row
->setSourceProperty('language', $language);
return parent::prepareRow($row);
}
public function getIds() {
$ids['vid']['type'] = 'integer';
$ids['language']['type'] = 'string';
$ids['language']['alias'] = 'lt';
return $ids;
}
}