I have generated a custom entity using Drupal Console.

drupal generate:entity:content 

However, there is one serious problem. All the default route for the various operation related to that entity are coming under /admin/.. route. Which prevent non-admins from accessing those pages even if given permission for example to edit it.

When I generate an entity called company. My routes are as below:

  • View Single Entiy: /admin/structure/company_entity/{company_entity}
  • Add Entity: /admin/structure/company_entity/add
  • Edit Entity: /admin/structure/company_entity/{company_entity}/edit
  • Delete Entity: /admin/structure/company_entity/{company_entity}/delete
  • List all Enitities: /admin/structure/company_entity

Where should we edit the module to override or change these settings.

1 Answer 1


You need to edit the entity class's annotation, at e.g. module_name/src/Entity/FooEntity.php.

This is an example of what you need from the Node entity class:

links = {
    "canonical" = "/node/{node}",
    "delete-form" = "/node/{node}/delete",
    "edit-form" = "/node/{node}/edit",
    "version-history" = "/node/{node}/revisions",
    "revision" = "/node/{node}/revisions/{node_revision}/view",

You'll probably need to rebuild cache for the changes to be reflected.

  • 1
    I figured it out a while ago and was about to post an answer. Great to see it already answered. :)
    – esafwan
    Jun 30, 2017 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.