Hi all,

I'm writing a module which defines custom entities, with custom routes, local tabs, etc.

What should I do to allow devel to show its local tab (devel) right where I have my entity's one?

This issue seems to be related to what I want to do, but can't get my head around it. And I can't find any documentation relating to this.

Because my routes are like this:

/admin/content/{mymodule_foo_entity}/1
/admin/content/{mymodule_foo_entity}/edit
/admin/content/{mymodule_foo_entity}/delete

My local tabs appear correctly on those pages (View, Edit, Delete). But I'd like to add devel as well.

I know the route automagically exists under /devel/{mymodule_foo_entity}/1, but I'd really like to have the tab.

Your help would be very appreciated :)

Cheers,
Jérémy

Comments

jchatard created an issue.

willzyx’s picture

Hi @jchatard probably you need to add a "base local task" (eg entity.{yourentity}.canonical) for your entity type or otherwise devel cannot hook his local task to your entities. Please post your code or otherwise is difficult analyze the problem :)

jchatard’s picture

Hi @willzyx

Thanks for your reply, here is my routing file:

entity.re_core_entities.program.collection:
  path: '/admin/content/program/list'
  defaults:
    _entity_list: 're_core_entities_program'
    _title: 'Programs'
  requirements:
    _permission: 'administer programs'

entity.re_core_entities.program.canonical:
  path: '/admin/content/program/{re_core_entities_program}'
  defaults:
    # Calls the view controller, defined in the annotation of the contact entity
    _entity_view: 're_core_entities_program'
    _title: 'Program content'
  requirements:
    # Calls the access controller of the entity, $operation 'view'
    _entity_access: 're_core_entities_program.view'

re_core_entities.program.form_add:
  path: '/admin/content/program/add'
  defaults:
    _entity_form: 're_core_entities_program.add'
    _title: 'Add a Program'
  requirements:
    _entity_create_access: 're_core_entities_program'


entity.re_core_entities.program.form_edit:
  path: '/admin/content/program/{re_core_entities_program}/edit'
  defaults:
  # Calls the form.edit controller, defined in the contact entity.
    _entity_form: re_core_entities_program.edit
    _title: 'Edit Program'
  requirements:
    _entity_access: 're_core_entities_program.edit'

entity.re_core_entities.program.form_delete:
  path: '/admin/content/program/{re_core_entities_program}/delete'
  defaults:
    # Calls the form.delete controller, defined in the contact entity.
    _entity_form: re_core_entities_program.delete
    _title: 'Delete Program'
  requirements:
    _entity_access: 're_core_entities_program.delete'

Here's an excerpt from the annotation:

*  links = {
*     "canonical"   = "/admin/content/program/{re_core_entities_program}",
*     "edit-form"   = "/admin/content/program/{re_core_entities_program}/edit",
*     "delete-form" = "/admin/content/program/{re_core_entities_program}/delete",
*     "collection"  = "/admin/content/program/list"
*   },

And here is the module.links.task.yml:

re_core_entities.program_collection:
  title: 'Programs'
  route_name: entity.re_core_entities.program.collection
  base_route: system.admin_content
  weight: 10

re_core_entities.program_view:
  title: View
  route_name: entity.re_core_entities.program.canonical
  base_route: entity.re_core_entities.program.canonical
  weight: 0


re_core_entities.program_edit:
  title: Edit
  route_name: entity.re_core_entities.program.form_edit
  base_route: entity.re_core_entities.program.canonical
  weight: 1

re_core_entities.program_delete_confirm:
  title: Delete
  route_name: entity.re_core_entities.program.form_delete
  base_route: entity.re_core_entities.program.canonical
  weight: 10