Drupal 8自定义实体菜单路径

Drupal 8自定义实体菜单路径,drupal,menu,parent,drupal-8,entities,Drupal,Menu,Parent,Drupal 8,Entities,使用Drupal控制台创建自定义实体时: drupal generate:entity:content 然后,默认情况下会生成菜单路径,它们工作得非常好,即在结构菜单中有两个条目用于列出实体和管理自定义实体,其中包括用于管理字段、管理表单显示和管理显示的子菜单 现在,为了避免弄乱结构菜单,我喜欢将模块中的所有自定义enitite收集到一个路径下的SystemController::systemAdminMenuBlockPage下 /admin/structure/MyCustomModule

使用Drupal控制台创建自定义实体时:

drupal generate:entity:content
然后,默认情况下会生成菜单路径,它们工作得非常好,即在结构菜单中有两个条目用于列出实体和管理自定义实体,其中包括用于管理字段、管理表单显示和管理显示的子菜单

现在,为了避免弄乱结构菜单,我喜欢将模块中的所有自定义enitite收集到一个路径下的SystemController::systemAdminMenuBlockPage下 /admin/structure/MyCustomModuleGroup/myCustomEntityType

通过将“MyCustomModuleGroup”插入实体注释和MyCustomEntityHtmlRouteProvider中的路径,这很容易。然后更新mymodule.links.task.yml的基本路径

但是,管理字段等的所有子菜单都将消失。这可能是因为他们不再有正确的父母

最后,我想介绍以下菜单项:

structure->CustomModule->CustomEntity1Type->Manage Fields
structure->CustomModule->CustomEntity1Type->Manage Form Display
structure->CustomModule->CustomEntity1Type->Manage Display.

structure->CustomModule->CustomEntity2Type->Manage Fields
等等


有人能解决这个问题吗?我假设有一种方法可以更改代码中的菜单链接父项,因为它肯定是在某处声明的,但我找不到它(花了一整天的时间尝试)。

我能够在custom_entity.links.menu.yml中使用它,如下所示:

entity.custom_entity.fields:
  title: 'Manage fields'
  route_name: entity.custom_entity.field_ui_fields
  description: 'Manage fields'
  parent: entity.custom_entity.collection
  weight: 1

entity.custom_entity.form-display:
  title: 'Manage form display'
  route_name: entity.entity_form_display.custom_entity.default
  description: 'Manage form display'
  parent: entity.custom_entity.collection
  weight: 2

entity.custom_entity.display:
  title: 'Manage display'
  route_name: entity.entity_view_display.custom_entity.default
  description: 'Manage display'
  parent: entity.custom_entity.collection
  weight: 3

成功了。非常感谢!在捆绑实体中这样做有什么好运气吗?我认为这需要在代码中完成,而不是在.yml配置中。但是,对于未绑定的实体,您的解决方案非常有效。很抱歉,在本项目中,目前无法使用捆绑包。但在我看来,确实有可能修改代码以使其正常工作。你可以接受我的回答作为你问题的解决办法;)