diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php index 71eebe8..2b9382e 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d6/MigrateUpgrade6Test.php @@ -76,10 +76,10 @@ protected function getEntityCounts() { 'node_type' => 13, 'rdf_mapping' => 7, 'search_page' => 2, - 'shortcut' => 2, + 'shortcut' => 1, 'shortcut_set' => 1, 'action' => 23, - 'menu' => 8, + 'menu' => 7, 'taxonomy_term' => 8, 'taxonomy_vocabulary' => 7, 'tour' => 4, diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php index 385a4e5..839b27c 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php @@ -76,10 +76,10 @@ protected function getEntityCounts() { 'node_type' => 6, 'rdf_mapping' => 7, 'search_page' => 2, - 'shortcut' => 6, + 'shortcut' => 5, 'shortcut_set' => 2, 'action' => 17, - 'menu' => 6, + 'menu' => 7, 'taxonomy_term' => 18, 'taxonomy_vocabulary' => 4, 'tour' => 4, diff --git a/core/modules/node/node.links.menu.yml b/core/modules/node/node.links.menu.yml index ae7a9af..db34628 100644 --- a/core/modules/node/node.links.menu.yml +++ b/core/modules/node/node.links.menu.yml @@ -6,3 +6,6 @@ entity.node_type.collection: node.add_page: title: 'Add content' route_name: node.add_page +node.add_menu: + class: \Drupal\node\Plugin\Menu\NodeMenuLink + deriver: \Drupal\node\Plugin\Derivative\NodeMenuLinkDeriver diff --git a/core/modules/node/src/Plugin/Derivative/NodeMenuLinkDeriver.php b/core/modules/node/src/Plugin/Derivative/NodeMenuLinkDeriver.php new file mode 100644 index 0000000..3dc3ddb --- /dev/null +++ b/core/modules/node/src/Plugin/Derivative/NodeMenuLinkDeriver.php @@ -0,0 +1,55 @@ +entityStorage = $entity_storage; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, $base_plugin_id) { + return new static( + $base_plugin_id, + $container->get('entity_type.manager')->getStorage('node_type') + ); + } + + /** + * {@inheritdoc} + */ + public function getDerivativeDefinitions($base_plugin_definition) { + $links = []; + $bundles = $this->entityStorage->loadMultiple(); + + foreach ($bundles as $id => $bundle) { + $links[$id] = [ + 'title' => $bundle->label(), + 'parent' => 'system.add', + 'route_name' => 'node.add', + 'route_parameters' => ['node_type' => $id], + ] + $base_plugin_definition; + } + + return $links; + } +} diff --git a/core/modules/node/src/Plugin/Menu/NodeMenuLink.php b/core/modules/node/src/Plugin/Menu/NodeMenuLink.php new file mode 100644 index 0000000..f288069 --- /dev/null +++ b/core/modules/node/src/Plugin/Menu/NodeMenuLink.php @@ -0,0 +1,10 @@ +systemManager->getBlockContents(); + } + + /** * Returns a theme listing. * * @return string diff --git a/core/modules/system/system.links.menu.yml b/core/modules/system/system.links.menu.yml index b5f9d87..8a40e88 100644 --- a/core/modules/system/system.links.menu.yml +++ b/core/modules/system/system.links.menu.yml @@ -3,6 +3,11 @@ system.admin: route_name: system.admin weight: 9 menu_name: admin +system.add: + title: 'Add any content' + route_name: system.add + weight: 10 + menu_name: add system.admin_content: title: Content description: 'Find and manage content.' diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index 9cfe2ca..abe1a2e 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -38,6 +38,14 @@ system.admin: requirements: _permission: 'access administration pages' +system.add: + path: '/content/add' + defaults: + _controller: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage' + _title: 'Add' + requirements: + _node_add_access: 'node' + system.admin_structure: path: '/admin/structure' defaults: diff --git a/core/modules/toolbar/toolbar.module b/core/modules/toolbar/toolbar.module index c7feaee..761a4c4 100644 --- a/core/modules/toolbar/toolbar.module +++ b/core/modules/toolbar/toolbar.module @@ -203,6 +203,41 @@ function toolbar_toolbar() { ], '#weight' => -15, ]; + + // The add element has a tray with the Add content menu. + $items['add'] = [ + '#type' => 'toolbar_item', + 'tab' => [ + '#type' => 'link', + '#title' => t('Add'), + '#url' => Url::fromRoute('system.add'), + '#attributes' => [ + 'title' => t('Add content menu'), + 'class' => ['toolbar-icon', 'toolbar-icon-add'], + // A data attribute that indicates to the client to defer loading of + // the admin menu subtrees until this tab is activated. Admin menu + // subtrees will not render to the DOM if this attribute is removed. + // The value of the attribute is intentionally left blank. Only the + // presence of the attribute is necessary. + 'data-drupal-subtrees' => '', + ], + ], + 'tray' => [ + '#heading' => t('Add content menu'), + '#attached' => $subtrees_attached, + 'toolbar_administration' => [ + '#pre_render' => [ + 'toolbar_prerender_toolbar_add_tray', + ], + '#type' => 'container', + '#attributes' => [ + 'class' => ['toolbar-menu-administration'], + ], + ], + ], + '#weight' => -14, + ]; + $hash_cacheability->applyTo($items['administration']); return $items; @@ -239,6 +274,24 @@ function toolbar_prerender_toolbar_administration_tray(array $element) { } /** + * Renders the toolbar's Add tray in the same way as the Administration tray. + */ +function toolbar_prerender_toolbar_add_tray(array $element) { + $menu_tree = \Drupal::service('toolbar.menu_tree'); + $parameters = new MenuTreeParameters(); + $parameters->setMinDepth(2)->setMaxDepth(2)->onlyEnabledLinks(); + $tree = $menu_tree->load('add', $parameters); + $manipulators = [ + ['callable' => 'menu.default_tree_manipulators:checkAccess'], + ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'], + ['callable' => 'toolbar_menu_navigation_links'], + ]; + $tree = $menu_tree->transform($tree, $manipulators); + $element['administration_menu'] = $menu_tree->build($tree); + return $element; +} + +/** * Adds toolbar-specific attributes to the menu link tree. * * @param \Drupal\Core\Menu\MenuLinkTreeElement[] $tree diff --git a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php index 7291dc2..3a07b56 100644 --- a/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php +++ b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php @@ -174,6 +174,7 @@ public function testMenuOptions() { '', '-- My account', '-- Log out', + '', '', '