function MenuLinkLocalized::prepareRow

Same name in other branches
  1. 10 core/modules/menu_link_content/src/Plugin/migrate/source/d7/MenuLinkLocalized.php \Drupal\menu_link_content\Plugin\migrate\source\d7\MenuLinkLocalized::prepareRow()
  2. 11.x core/modules/menu_link_content/src/Plugin/migrate/source/d7/MenuLinkLocalized.php \Drupal\menu_link_content\Plugin\migrate\source\d7\MenuLinkLocalized::prepareRow()

Overrides MenuLink::prepareRow

File

core/modules/menu_link_content/src/Plugin/migrate/source/d7/MenuLinkLocalized.php, line 43

Class

MenuLinkLocalized
Drupal 7 localized menu link translations source from database.

Namespace

Drupal\menu_link_content\Plugin\migrate\source\d7

Code

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.