diff --git a/core/modules/config/src/Tests/ConfigImportAllTest.php b/core/modules/config/src/Tests/ConfigImportAllTest.php index baeacb9..367c06e 100644 --- a/core/modules/config/src/Tests/ConfigImportAllTest.php +++ b/core/modules/config/src/Tests/ConfigImportAllTest.php @@ -4,6 +4,7 @@ use Drupal\Core\Config\StorageComparer; use Drupal\filter\Entity\FilterFormat; +use Drupal\menu_link_content\Entity\MenuLinkContent; use Drupal\system\Tests\Module\ModuleTestBase; use Drupal\shortcut\Entity\Shortcut; use Drupal\taxonomy\Entity\Term; @@ -92,6 +93,10 @@ public function testInstallUninstall() { $shortcuts = Shortcut::loadMultiple(); entity_delete_multiple('shortcut', array_keys($shortcuts)); + // Delete any menu links so the menu_link_content can be uninstalled. + $menu_links = MenuLinkContent::loadMultiple(); + entity_delete_multiple('menu_link_content', array_keys($menu_links)); + system_list_reset(); $all_modules = system_rebuild_module_data(); diff --git a/core/modules/migrate_drupal_ui/src/Tests/d6/MigrateUpgrade6Test.php b/core/modules/migrate_drupal_ui/src/Tests/d6/MigrateUpgrade6Test.php index 50829f0..46f0470 100644 --- a/core/modules/migrate_drupal_ui/src/Tests/d6/MigrateUpgrade6Test.php +++ b/core/modules/migrate_drupal_ui/src/Tests/d6/MigrateUpgrade6Test.php @@ -62,7 +62,7 @@ protected function getEntityCounts() { 'tour' => 4, 'user' => 7, 'user_role' => 6, - 'menu_link_content' => 4, + 'menu_link_content' => 5, 'view' => 12, 'date_format' => 11, 'entity_form_display' => 15, diff --git a/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php b/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php index 77bc2ab..2537f82 100644 --- a/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php +++ b/core/modules/migrate_drupal_ui/src/Tests/d7/MigrateUpgrade7Test.php @@ -63,7 +63,7 @@ protected function getEntityCounts() { 'tour' => 4, 'user' => 4, 'user_role' => 3, - 'menu_link_content' => 7, + 'menu_link_content' => 8, 'view' => 12, 'date_format' => 11, 'entity_form_display' => 16, diff --git a/core/profiles/standard/standard.install b/core/profiles/standard/standard.install index 0a40ce6..2cb4cdb 100644 --- a/core/profiles/standard/standard.install +++ b/core/profiles/standard/standard.install @@ -5,6 +5,7 @@ * Install, update and uninstall functions for the standard installation profile. */ +use Drupal\menu_link_content\Entity\MenuLinkContent; use Drupal\user\Entity\User; use Drupal\user\RoleInterface; use Drupal\shortcut\Entity\Shortcut; @@ -48,6 +49,14 @@ function standard_install() { // Allow authenticated users to use shortcuts. user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access shortcuts')); + // Populate the main menu. + $home = MenuLinkContent::create(array( + 'title' => t('Home'), + 'link' => array('uri' => 'internal:/'), + 'menu_name' => 'main', + )); + $home->save(); + // Populate the default shortcut set. $shortcut = Shortcut::create(array( 'shortcut_set' => 'default', @@ -72,3 +81,42 @@ function standard_install() { // Enable the admin theme. \Drupal::configFactory()->getEditable('node.settings')->set('use_admin_theme', TRUE)->save(TRUE); } + +/** + * Replace the static Home link with a dynamic one. + */ +function standard_update_8202() { + // Fetch the current standard.front_page options + $home_manager = \Drupal::service('plugin.manager.menu.link'); + try { + $home_current = $home_manager->getDefinition('standard.front_page'); + // Menu item standard.front_page has been altered, let's use those options + $home_new = MenuLinkContent::create(array( + 'title' => t('Home'), + 'link' => array('uri' => 'internal:/'), + 'menu_name' => 'main', + 'weight' => $home_current['weight'], + 'enabled' => $home_current['enabled'], + )); + $home_new->save(); + // Disable standard.front_page since it can't be deleted + if ($home_current['enabled']) { + $home_current['enabled'] = 0; + $home_manager->updateDefinition('standard.front_page', $home_current); + } + } + catch (\Drupal\Component\Plugin\Exception\PluginNotFoundException $e) { + // Menu item standard.front_page has not been altered, let's use default options + $home_new = MenuLinkContent::create(array( + 'title' => t('Home'), + 'link' => array('uri' => 'internal:/'), + 'menu_name' => 'main', + 'weight' => 0, + 'enabled' => 1, + )); + $home_new->save(); + } + // Clear menu cache + $cache = \Drupal::cache('menu'); + $cache->deleteAll(); +} diff --git a/core/profiles/standard/standard.links.menu.yml b/core/profiles/standard/standard.links.menu.yml deleted file mode 100644 index 2278b21..0000000 --- a/core/profiles/standard/standard.links.menu.yml +++ /dev/null @@ -1,4 +0,0 @@ -standard.front_page: - title: 'Home' - route_name: '' - menu_name: main