public static function MenuLinksController::importMenuLinksForce in Structure Sync 8
Same name and namespace in other branches
- 2.x src/Controller/MenuLinksController.php \Drupal\structure_sync\Controller\MenuLinksController::importMenuLinksForce()
Function to import (create) all menu links that need to be imported.
1 call to MenuLinksController::importMenuLinksForce()
- MenuLinksController::importMenuLinks in src/
Controller/ MenuLinksController.php - Function to import menu links.
File
- src/
Controller/ MenuLinksController.php, line 426
Class
- MenuLinksController
- Controller for syncing menu links.
Namespace
Drupal\structure_sync\ControllerCode
public static function importMenuLinksForce($menus, &$context) {
foreach ($menus as $menuLink) {
MenuLinkContent::create([
'title' => $menuLink['title'],
'link' => [
'uri' => $menuLink['uri'],
'title' => $menuLink['link_title'],
],
'menu_name' => $menuLink['menu_name'],
'expanded' => $menuLink['expanded'] === '1' ? TRUE : FALSE,
'enabled' => $menuLink['enabled'] === '1' ? TRUE : FALSE,
'parent' => $menuLink['parent'],
'description' => $menuLink['description'],
'weight' => $menuLink['weight'],
'langcode' => $menuLink['langcode'],
'uuid' => $menuLink['uuid'],
])
->save();
if (array_key_exists('drush', $context) && $context['drush'] === TRUE) {
drush_log('Imported "' . $menuLink['title'] . '" into "' . $menuLink['menu_name'] . '" menu', 'ok');
}
StructureSyncHelper::logMessage('Imported "' . $menuLink['title'] . '" into "' . $menuLink['menu_name'] . '" menu');
}
}