class MenuLinkLocalized
Same name and namespace in other branches
- 11.x core/modules/menu_link_content/src/Plugin/migrate/source/d7/MenuLinkLocalized.php \Drupal\menu_link_content\Plugin\migrate\source\d7\MenuLinkLocalized
- 10 core/modules/menu_link_content/src/Plugin/migrate/source/d7/MenuLinkLocalized.php \Drupal\menu_link_content\Plugin\migrate\source\d7\MenuLinkLocalized
Drupal 7 localized menu link translations source from database.
Plugin annotation
@MigrateSource(
id = "d7_menu_link_localized",
source_module = "i18n_menu"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait implements \Drupal\Component\Plugin\PluginBase
- class \Drupal\migrate\Plugin\migrate\source\SourcePluginBase extends \Drupal\migrate\Plugin\MigrateSourceInterface, \Drupal\migrate\Event\RollbackAwareInterface implements \Drupal\Core\Plugin\PluginBase
- class \Drupal\migrate\Plugin\migrate\source\SqlBase extends \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\migrate\Plugin\RequirementsInterface implements \Drupal\migrate\Plugin\migrate\source\SourcePluginBase
- class \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase extends \Drupal\Component\Plugin\DependentPluginInterface uses \Drupal\Core\Entity\DependencyTrait implements \Drupal\migrate\Plugin\migrate\source\SqlBase
- class \Drupal\menu_link_content\Plugin\migrate\source\MenuLink implements \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase
- class \Drupal\menu_link_content\Plugin\migrate\source\d7\MenuLinkLocalized implements \Drupal\menu_link_content\Plugin\migrate\source\MenuLink
- class \Drupal\menu_link_content\Plugin\migrate\source\MenuLink implements \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase
- class \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase extends \Drupal\Component\Plugin\DependentPluginInterface uses \Drupal\Core\Entity\DependencyTrait implements \Drupal\migrate\Plugin\migrate\source\SqlBase
- class \Drupal\migrate\Plugin\migrate\source\SqlBase extends \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\migrate\Plugin\RequirementsInterface implements \Drupal\migrate\Plugin\migrate\source\SourcePluginBase
- class \Drupal\migrate\Plugin\migrate\source\SourcePluginBase extends \Drupal\migrate\Plugin\MigrateSourceInterface, \Drupal\migrate\Event\RollbackAwareInterface implements \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait implements \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of MenuLinkLocalized
File
-
core/
modules/ menu_link_content/ src/ Plugin/ migrate/ source/ d7/ MenuLinkLocalized.php, line 16
Namespace
Drupal\menu_link_content\Plugin\migrate\source\d7View source
class MenuLinkLocalized extends MenuLink {
/**
* {@inheritdoc}
*/
public function query() {
$query = parent::query();
$query->condition('ml.i18n_tsid', '0', '<>');
// The first row in a translation set is the source.
$query->orderBy('ml.i18n_tsid');
return $query;
}
/**
* {@inheritdoc}
*/
public function fields() {
$fields = [
'ml_language' => $this->t('Menu link ID of the source language menu link.'),
'skip_source_translation' => $this->t('Menu link description translation.'),
];
return parent::fields() + $fields;
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
$row->setSourceProperty('skip_source_translation', TRUE);
// Get the mlid for the source menu_link.
$source_mlid = $this->select('menu_links', 'ml')
->fields('ml', [
'mlid',
])
->condition('i18n_tsid', $row->getSourceProperty('i18n_tsid'))
->orderBy('mlid')
->range(0, 1)
->execute()
->fetchField();
if ($source_mlid == $row->getSourceProperty('mlid')) {
$row->setSourceProperty('skip_source_translation', FALSE);
}
$row->setSourceProperty('mlid', $source_mlid);
return parent::prepareRow($row);
}
/**
* {@inheritdoc}
*/
public function getIds() {
$ids['language']['type'] = 'string';
$ids['language']['alias'] = 'ml';
return parent::getIds() + $ids;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.