You are here

public function MenuLinkTranslation::query in Drupal 10

Same name in this branch
  1. 10 core/modules/menu_link_content/src/Plugin/migrate/source/d6/MenuLinkTranslation.php \Drupal\menu_link_content\Plugin\migrate\source\d6\MenuLinkTranslation::query()
  2. 10 core/modules/menu_link_content/src/Plugin/migrate/source/d7/MenuLinkTranslation.php \Drupal\menu_link_content\Plugin\migrate\source\d7\MenuLinkTranslation::query()
Same name and namespace in other branches
  1. 8 core/modules/menu_link_content/src/Plugin/migrate/source/d6/MenuLinkTranslation.php \Drupal\menu_link_content\Plugin\migrate\source\d6\MenuLinkTranslation::query()
  2. 9 core/modules/menu_link_content/src/Plugin/migrate/source/d6/MenuLinkTranslation.php \Drupal\menu_link_content\Plugin\migrate\source\d6\MenuLinkTranslation::query()

Return value

\Drupal\Core\Database\Query\SelectInterface

Overrides MenuLink::query

File

core/modules/menu_link_content/src/Plugin/migrate/source/d6/MenuLinkTranslation.php, line 29

Class

MenuLinkTranslation
Drupal 6 i18n menu link translations source from database.

Namespace

Drupal\menu_link_content\Plugin\migrate\source\d6

Code

public function query() {

  // Ideally, the query would return rows for each language for each menu link
  // with the translations for both the title and description or just the
  // title 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 title or description. The
  // method prepareRow() is then used to obtain the translation for the other
  // property.
  // The query starts with the same query as menu_link.
  $query = parent::query();

  // Add in the property, which is either title or description. Cast the mlid
  // to text so PostgreSQL can make the join.
  $query
    ->leftJoin(static::I18N_STRING_TABLE, 'i18n', 'CAST([ml].[mlid] 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');
  $query
    ->addField('lt', 'translation');
  return $query;
}