diff --git a/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php b/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php index eedf057..d04f5f7 100755 --- a/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php +++ b/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php @@ -108,16 +108,29 @@ class ExtraLinks extends DeriverBase implements ContainerDeriverInterface { // See admin_toolbar_tools_entity_type_build(). if ($entity_type->get('admin_toolbar_tools_add_link')) { if ($entity_type->hasKey('bundle') && $this->routeExists("entity.{$entity_type_id}.add_page")) { - // If the entity has bundles, we add both the add-page link, and links to - // add each type beneath it. - $links["admin_toolbar_tools.{$entity_type_id}.add_page"] = [ + // Add a link to the collection page for an entity type. + $top_link = "admin_toolbar_tools.{$entity_type_id}.collection"; + $links[$top_link] = [ + 'title' => t('@entity-type', [ + '@entity-type' => $entity_type->getLabel(), + ]), + 'route_name' => "entity.{$entity_type_id}.collection", + 'menu_name' => 'admin', + 'parent' => 'system.admin_content', + ] + $base_plugin_definition; + + // If the entity has bundles, we add both the add-page link, and links + // to add each type beneath it. + $parent_link = "admin_toolbar_tools.{$entity_type_id}.add_page"; + // $parent_link = "system.admin_content_{$entity_type_id}"; + $links[$parent_link] = [ 'title' => t('Add @entity-type', [ '@entity-type' => $entity_type->getSingularLabel(), ]), 'route_name' => "entity.{$entity_type_id}.add_page", 'menu_name' => 'admin', - 'parent' => 'system.admin_content', - ]; + 'parent' => $base_plugin_definition['id'] . ':' . $top_link, + ] + $base_plugin_definition; $bundles = \Drupal::service('entity_type.bundle.info') ->getBundleInfo($entity_type_id); @@ -125,21 +138,24 @@ class ExtraLinks extends DeriverBase implements ContainerDeriverInterface { $bundle_argument = $bundle_entity_type_id; } else { - $bundle_argument = $entity_type->getKey('bundle'); + $bundle_argument = $entity_type->getKey('bundle_entity_type'); } foreach ($bundles as $bundle_name => $bundle_info) { - $links["admin_toolbar_tools.{$entity_type_id}.add.{$bundle_name}"] = [ - 'title' => $bundle_info['label'], + $links["{$parent_link}.{$bundle_name}"] = [ + 'title' => t('@bundle', [ + '@bundle' => $bundle_info['label'], + ]), 'route_name' => "entity.{$entity_type_id}.add_form", - 'parent' => "admin_toolbar_tools.{$entity_type_id}.add_page", + 'menu_name' => 'admin', + 'parent' => $base_plugin_definition['id'] . ':' . $parent_link, 'route_parameters' => [ $bundle_argument => $bundle_name, ], - ]; + ] + $base_plugin_definition; } } elseif (!$entity_type->hasKey('bundle') && $this->routeExists("entity.{$entity_type_id}.add_form")) { - // If the entity has no bundles, but has an add-form link, add just that. + // If the entity has no bundles, but has an add-form link, add that. $links["{$entity_type_id}.add_form"] = [ 'title' => t('Add @entity-type', [ '@entity-type' => $entity_type->getSingularLabel(),