0

I have a module I am upgrading from 7 to 8. I am working on the mymodule.routing.yml file

mymodule.admin:
  path: '/admin/structure/mymodule'
  route_name:mymodule
defaults:
  _controller: '\Drupal\mymodule\Controller\QuicktabsController::adminOverview'
  _title: 'mymodule'
requirements:
 _permission: 'administer mymodule'

Now when I try to enable my module the log shows this error

Uncaught PHP Exception Drupal\\Component\\Plugin\\Exception\\PluginException: "Plugin (mymodule.admin) definition must include "route_name"" at /srv/www/appdocroot/releases/20150428151557/core/lib/Drupal/Core/Menu/LocalTaskManager.php line 161

I assume this error means that the snippet of code from my routing.yml file is the offending piece.

I have gone through the upgrade tutorial on the drupal site and it does not include the "route_name" field in the section. I originally tried it without and later put it in when I discovered the error.

Am I correct in my assumption of where the error is coming from? If thats true what is wrong with my route_name field?

1
  • As side note, indentation is important in a YAML file. Without that, the route is not recognised since you are not providing the required information.
    – avpaderno
    Commented Jun 20, 2015 at 6:22

1 Answer 1

3

That code snippet looks very strange, is it really like that in your yml file or is it just wrong in the question here?

There is no route_name key inside the definition, and everything needs to be inside the first key, which is the route name. There are plenty of examples in system.routing.yml. Always try to find actual examples in Drupal core and not some online tutorials when you're not sure, as they might be outdated.

Make sure that you always use two spaces for indentation.

Your example should look like this:

mymodule.admin:
  path: '/admin/structure/mymodule'
  defaults:
    _controller: '\Drupal\mymodule\Controller\QuicktabsController::adminOverview'
    _title: 'mymodule'
  requirements:
    _permission: 'administer mymodule'

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.