hechoendrupal / drupal-console

The Drupal CLI. A tool to generate boilerplate code, interact with and debug Drupal.
http://drupalconsole.com
GNU General Public License v2.0
939 stars 560 forks source link

generate:entity:content base-path for the content entity routes does not work #2974

Open liquidcms opened 7 years ago

liquidcms commented 7 years ago

At least from the interactive prompt when i enter a value of /admin/structure/reservation for the base-path for the content entity routes, i still get the routes being at admin/structure.

this leads to:

unless, this is due to my entering the path as simply /admin/structure the first time and DC not being able to update when entity is recreated.. which i guess would be a different bug.

liquidcms commented 7 years ago

hmm... no, it seems as though DC simply can't edit/delete anything that has been added to a custom module. I think (so far) only option to edit an entity added to a module is to delete the entire module and start from scratch.

liquidcms commented 7 years ago

Nope, even if i redo module from scratch and enter base path at command line; it still hard codes it to the wrong place

jmolivas commented 7 years ago

@liquidcms You are right, code generation only creates files. It also updates files but by appending more info not by changing.

Can you clarify what is the proper path to work on a PR to have this issue fixed.

liquidcms commented 7 years ago

good question and i think it is going to be different for each case.

but in general i don't think you want to clutter up items at the main Drupal admin parents such as admin/structure, etc.

also, main point of my post was i don't think it was possible to set the routing path with the option.

as it turned out i was creating 2 entities for my module; which give 4 menu items. Ideally they shouldnt all be at admin/structure. this doesnt seem to be correct.. but best i could come up with:

main entity is a reservation and secondary entity is a reservation category, so i went with:

and i can only set this up by editing the [module].links.menu.yml - which was easy and worked well.

mithenks commented 7 years ago

Hello, I would like to report more information on this bug based on my experience.

I'm trying to create a new Content Entity using the command generate:entity:content. I want that the routes for this content entity have as base-path something different from the default /admin/structure; say, for example, that I want to put these routes in /admin/config path.

You can find the output of the drupal console command in drupal_console_issue_2974_log_1.txt.

After this, the content entity routes are placed under /admin/structure.
If I look at the file _modules/custom/test_module/testmodule.links.menu.yml generated by the drupal console command, I notice that the parent parameter is not set according to what I have specified (see drupal_console_issue_2974_log_2.txt)

Given a quick look at the source code, I have noticed that the template used to generate this file has the parent line hard-coded (see: links.menu-entity-content.yml.twig)

So, to solve this, I think we need to:

  1. Calculate the route in which put the content entity links from the config path specified by the user (see: line 89 of EntityContentGenerator.php)
  2. Pass this value to the twig template and write down to the generated file

Hope this helps.

Regards, Michele

hjuarez20 commented 5 years ago

The content generated by generate:entity:content command will be change in Drupal Console 2.0