diff --git a/core/modules/config/src/Tests/ConfigImportAllTest.php b/core/modules/config/src/Tests/ConfigImportAllTest.php index 459be7a..cfadce7 100644 --- a/core/modules/config/src/Tests/ConfigImportAllTest.php +++ b/core/modules/config/src/Tests/ConfigImportAllTest.php @@ -7,7 +7,7 @@ use Drupal\system\Tests\Module\ModuleTestBase; use Drupal\shortcut\Entity\Shortcut; use Drupal\taxonomy\Entity\Term; - +use Drupal\menu_link_content\Entity\MenuLinkContent; /** * Tests the largest configuration import possible with all available modules. * @@ -92,6 +92,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 404f21b..493b5f0 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 86f1ca9..39401fb 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 2f567ab..6ab0d00 100644 --- a/core/profiles/standard/standard.install +++ b/core/profiles/standard/standard.install @@ -8,6 +8,7 @@ use Drupal\user\Entity\User; use Drupal\user\RoleInterface; use Drupal\shortcut\Entity\Shortcut; +use Drupal\menu_link_content\Entity\MenuLinkContent; /** * Implements hook_install(). @@ -48,6 +49,14 @@ function standard_install() { // Allow authenticated users to use shortcuts. user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['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([ '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' => ['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' => ['uri' => 'internal:/'], + 'menu_name' => 'main', + 'weight' => 0, + 'enabled' => 1, + )); + $home_new->save(); + } + // Clear menu cache + $cache = \Drupal::cache('menu'); + $cache->deleteAll(); +} \ No newline at end of file diff --git a/core/profiles/standard/standard.links.menu.yml b/core/profiles/standard/standard.links.menu.yml index 2278b21..e69de29 100644 --- a/core/profiles/standard/standard.links.menu.yml +++ b/core/profiles/standard/standard.links.menu.yml @@ -1,4 +0,0 @@ -standard.front_page: - title: 'Home' - route_name: '' - menu_name: main