public function TermLocalizedTranslation::query in Drupal 8
Same name in this branch
- 8 core/modules/taxonomy/src/Plugin/migrate/source/d6/TermLocalizedTranslation.php \Drupal\taxonomy\Plugin\migrate\source\d6\TermLocalizedTranslation::query()
- 8 core/modules/taxonomy/src/Plugin/migrate/source/d7/TermLocalizedTranslation.php \Drupal\taxonomy\Plugin\migrate\source\d7\TermLocalizedTranslation::query()
Same name and namespace in other branches
- 9 core/modules/taxonomy/src/Plugin/migrate/source/d6/TermLocalizedTranslation.php \Drupal\taxonomy\Plugin\migrate\source\d6\TermLocalizedTranslation::query()
Return value
\Drupal\Core\Database\Query\SelectInterface
Overrides Term::query
File
- core/
modules/ taxonomy/ src/ Plugin/ migrate/ source/ d6/ TermLocalizedTranslation.php, line 20
Class
- TermLocalizedTranslation
- Gets i18n taxonomy terms from source database.
Namespace
Drupal\taxonomy\Plugin\migrate\source\d6Code
public function query() {
// Ideally, the query would return rows for each language for each taxonomy
// term with the translations for both the name and description or just the
// name translation or just the description translation. That query quickly
// became complex and would be difficult to maintain.
// Therefore, build a query based on i18nstrings table where each row has
// the translation for only one property, either name or description. The
// method prepareRow() is then used to obtain the translation for the other
// property.
$query = parent::query();
$query
->addField('td', 'language', 'td.language');
// Add in the property, which is either name or description.
// Cast td.tid as char for PostgreSQL compatibility.
$query
->leftJoin('i18n_strings', 'i18n', 'CAST(td.tid AS CHAR(255)) = i18n.objectid');
$query
->addField('i18n', 'lid');
$query
->addField('i18n', 'property');
// Add in the translation for the property.
$query
->innerJoin('locales_target', 'lt', 'i18n.lid = lt.lid');
$query
->addField('lt', 'language', 'lt.language');
$query
->addField('lt', 'translation');
return $query;
}