0

I've installed Drupal 8.5.4 and followed these two steps to create a module and an entity type:

  1. Ran drupal gm and filled in the info
  2. Ran drupal geco and filled in the info (No bundles, No translation, No revisions)
  3. Ran drush en mynewmodulename
  4. Ran drush re

Out of the box, refreshing the Drupal main page throws an error complaining that the route is not found.

I had to manually create the module route file and fill it with all the paths from the entity generated files in order to pass the error and get the main page to render.

Now I am getting entity type not exist error.

e.g. routing entries I have added to mynewmodule.routing.yml

entity.mynewmodule_myentityname.add_form:
  path: '/mynewmodule/myentityname/add'
  defaults:
    _entity_form: mynewmodule_myentityname.add
    _title: 'Add myentityname'
  requirements:
    _entity_create_access: 'mynewmodule_myentityname'

I expected the entity forms and list page to work straightaway after creating it using Drupal console. What am I doing wrong?

EDIT: I've also noticed that there is no table created in the database for the new entity.

  • Obviously there is something wrong, because normally the entity routes are built automatically (look for the handler "route_provider" in the annotations of your entity class). Did you check the error log? – 4k4 Jun 27 '18 at 9:22
  • The router provider is referring to one of the generated classes that extends AdminHtmlRouteProvider and implements getRoutes and getSettingsFormRoute. Is this class supposed to replace the routing yml? If yes why is it not working? – Bishoy Jun 27 '18 at 13:17
  • When you say log, do you mean the apache error log? – Bishoy Jun 27 '18 at 13:18
  • Yes, exactly, route provider replaced in the early days of D8 the routing yaml for entity routes. I just ran step 1 - 3 in Drupal Console 1.8, this takes only a few seconds and I get a new entity without errors and all routes are accessible from the UI. I don't know what is wrong with your site, but since you generate a lot of php code, check for php errors in Drupal watchdog and the apache error log. – 4k4 Jun 27 '18 at 13:27
  • 1
    Try a different module name and entity id so you are sure you have a fresh install of the module when you run drush en. Or a fresh test site. I'm afraid without error message or other details there is nothing to answer here, because the two console commands are correct. – 4k4 Jun 28 '18 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.