protected function MenuExportForm::exportMenus in Menu Import and Export 8
1 call to MenuExportForm::exportMenus()
- MenuExportForm::submitForm in src/
Form/ MenuExportForm.php - Form submission handler.
File
- src/
Form/ MenuExportForm.php, line 71
Class
- MenuExportForm
- Configure Menu Export settings.
Namespace
Drupal\menu_export\FormCode
protected function exportMenus() {
$menus = $this
->config('menu_export.settings')
->get('menus');
if (empty($menus)) {
return false;
}
$config = $this
->config('menu_export.export_data');
$config
->delete()
->save();
foreach ($menus as $menu) {
$menuLinkIds = \Drupal::entityQuery('menu_link_content')
->condition('menu_name', $menu)
->execute();
$menuLinks = MenuLinkContent::loadMultiple($menuLinkIds);
foreach ($menuLinks as $link) {
if (!empty($link)) {
$linkArray = $link
->toArray();
foreach ($linkArray as $key => $linkArrayItem) {
$linkData[$key] = reset($linkArrayItem);
}
//$data[$link->id()] = $linkData;
$config
->set($link
->id(), $linkData);
unset($linkData);
}
}
}
$config
->save();
return true;
}