0

I have created and installed custom module without additional code[with mymodule.info and mymodule.module].But after I created

mymodule.links.menu.yml and mymodule.routing.yml i am grtting error like "The website encountered an unexpected error" code mymodule.links.menu.yml

   mymodule.admin_form
     title: Upload IELTS Test Dates
     parent: cedar.admin_index
     weight: 100
     route_name : mymodule.admin_form

and code inside mymodule.routing.yml

 mymodule.settings:
   path: '/admin/config/services/migs'
   defaults:
     _controller: '\Drupal\quotesapi\Controller\MymoduleController::settings'
     _title: 'My module settings'
   requirements:
     _permission: 'administer site configuration'

I checked the watchdog and found a RouteNotFoundException. How do I fix this?

  • 1
    It’s not possible to debug a site without access to it - once you’ve checked your server and Drupal’s error logs, and done further research on the error messages that you find there, if you still have a specific question about your code, please ask a question containing full details of the error, and a snippet of code that can be used to reproduce it. Many thanks – Clive Nov 12 '17 at 14:36
  • Can I get my site, if I comment those code in mymodule.links.menu.yml and mymodule.routing.yml ? I don't need that module. – user49951 Nov 12 '17 at 14:44
  • If that's what's causing the problem, I'd imagine that will work, yes. You'll probably need to clear caches – Clive Nov 12 '17 at 14:50
  • I have updated my question.Now I couldn't see admin pages.It's showing the unexpected error for all pages.So my question is can I get my site back after commenting those code? – user49951 Nov 12 '17 at 14:59
  • It's impossible to say from here - try it and see what happens. If the links/routing file are invalid in some way then commenting them out or removing them entirely, followed by a cache rebuild, should be enough to fix it. If it doesn't, you need to find out what the error is by looking in the watchdog (/admin/reports/dblog). If you can't get to that page, look at the most recent entry in the watchdog table in the database with type php, a combination of the message and variables column will get you the real error message – Clive Nov 12 '17 at 15:07
0

It looks like a simple naming error. Your route name in the links file is:

route_name : mymodule.admin_form

But in your routing.yml you have:

 mymodule.settings:

Update one or the other so they both match, clear the cache, and it should work.

  • How can I clear cache without getting admin page ?Is it by clearing cache tables? – user49951 Nov 12 '17 at 16:30
  • I have added missing route name and clear the cache.But it still showing the same in watchdog. – user49951 Nov 12 '17 at 16:53
0

Change:

mymodule.admin_form

By

mymodule.admin_form:

Change:

route_name : mymodule.admin_form

By

route_name : mymodule.settings

Note: check the official documentation: on this page, there is an example of the use of the file: links.menu.yml. The file name must end in ":". and in the route_name parameter you must refer to the name of the route that is in the routing.yml file.

Your Answer

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