X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Fmenu_link_content%2Fsrc%2FPlugin%2Fmigrate%2Fsource%2Fd6%2FMenuLinkTranslation.php;fp=web%2Fcore%2Fmodules%2Fmenu_link_content%2Fsrc%2FPlugin%2Fmigrate%2Fsource%2Fd6%2FMenuLinkTranslation.php;h=983c3159914a6126ec821be8760507e417e32713;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=0000000000000000000000000000000000000000;hpb=74df008bdbb3a11eeea356744f39b802369bda3c;p=yaffs-website diff --git a/web/core/modules/menu_link_content/src/Plugin/migrate/source/d6/MenuLinkTranslation.php b/web/core/modules/menu_link_content/src/Plugin/migrate/source/d6/MenuLinkTranslation.php new file mode 100644 index 000000000..983c31599 --- /dev/null +++ b/web/core/modules/menu_link_content/src/Plugin/migrate/source/d6/MenuLinkTranslation.php @@ -0,0 +1,92 @@ +leftJoin(static::I18N_STRING_TABLE, 'i18n', 'CAST(ml.mlid as CHAR(255)) = i18n.objectid'); + $query->isNotNull('i18n.lid'); + $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; + } + + /** + * {@inheritdoc} + */ + public function prepareRow(Row $row) { + parent::prepareRow($row); + + // Save the translation for this property. + $property_in_row = $row->getSourceProperty('property'); + + // Set the i18n string table for use in I18nQueryTrait. + $this->i18nStringTable = static::I18N_STRING_TABLE; + // Get the translation for the property not already in the row and save it + // in the row. + $property_not_in_row = ($property_in_row == 'title') ? 'description' : 'title'; + return $this->getPropertyNotInRowTranslation($row, $property_not_in_row, 'mlid', $this->idMap); + } + + /** + * {@inheritdoc} + */ + public function fields() { + $fields = [ + 'language' => $this->t('Language for this menu.'), + 'title_translated' => $this->t('Menu link title translation.'), + 'description_translated' => $this->t('Menu link description translation.'), + ]; + return parent::fields() + $fields; + } + + /** + * {@inheritdoc} + */ + public function getIds() { + $ids['language']['type'] = 'string'; + return parent::getIds() + $ids; + } + +}