TermTranslation.php in Drupal 10
File
core/modules/taxonomy/src/Plugin/migrate/source/d7/TermTranslation.php
View source
<?php
namespace Drupal\taxonomy\Plugin\migrate\source\d7;
use Drupal\migrate\Row;
class TermTranslation extends Term {
public function query() {
$query = parent::query();
if ($this->database
->schema()
->fieldExists('taxonomy_term_data', 'language')) {
$query
->addField('td', 'language', 'td_language');
}
if ($this->database
->schema()
->fieldExists('taxonomy_vocabulary', 'i18n_mode')) {
$query
->addField('tv', 'i18n_mode');
$query
->condition('tv.i18n_mode', [
'0',
'1',
], 'NOT IN');
}
else {
$query
->alwaysFalse();
}
return $query;
}
public function prepareRow(Row $row) {
if (!parent::prepareRow($row)) {
return FALSE;
}
$row
->setSourceProperty('language', $row
->getSourceProperty('td_language'));
}
public function fields() {
$fields = [
'language' => $this
->t('Language for this term.'),
'name_translated' => $this
->t('Term name translation.'),
'description_translated' => $this
->t('Term description translation.'),
];
return parent::fields() + $fields;
}
public function getIds() {
$ids['language']['type'] = 'string';
$ids['language']['alias'] = 'td';
return parent::getIds() + $ids;
}
}