Router can't find route in LanguageNegotiation plugin route name I'm having to write a new LanguageNegotiation plugin for an API because the language is not the first part of the URL (it's the third). But D8 refuses to recognise the route to the plugin for the config menu item.

I have been following the Language module itself as a model and there is no other mention of an equivalent route name for any of the other LanguageNegotiation plugins. I have tried replacing 'doublespeak' with 'language' in the route name (no change).

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "doublespeak.negotiation_api_url" does not exist. in Drupal\Core\Routing\RouteProvider-&gt;getRouteByName() 


So the doublespeak.routing.yml looks like this:

doublespeak.negotiation_api_url:
  path: '/admin/config/regional/language/detection/apiurl'
  defaults:
    _form: 'Drupal\doublespeak\Form\NegotiationApiUrlForm'
    _title: 'API URL language detection configuration'
  requirements:
    _permission: 'administer languages'


And the start of the plugin is this:

namespace Drupal\doublespeak\Plugin\LanguageNegotiation;

use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\PathProcessor\InboundPathProcessorInterface;
use Drupal\Core\PathProcessor\OutboundPathProcessorInterface;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\Url;
use Drupal\language\LanguageNegotiationMethodBase;
use Drupal\language\LanguageSwitcherInterface;
use Symfony\Component\HttpFoundation\Request;

/**
 * Class for identifying language in an API URL via an infix value.
 *
 * @LanguageNegotiation(
 *   id = \Drupal\doublespeak\Plugin\LanguageNegotiation\LanguageNegotiationApiUrl::METHOD_ID,
 *   types = {\Drupal\Core\Language\LanguageInterface::TYPE_INTERFACE,
 *   \Drupal\Core\Language\LanguageInterface::TYPE_CONTENT,
 *   \Drupal\Core\Language\LanguageInterface::TYPE_URL},
 *   weight = -10,
 *   name = @Translation("API URL"),
 *   description = @Translation("Language from an API URL (/api/&lt;channel&gt;/&lt;market-language&gt;/refdata/&lt;&gt;)."),
 *   config_route_name = "doublespeak.negotiation_api_url"
 * )
 */
class LanguageNegotiationApiUrl extends LanguageNegotiationMethodBase implements InboundPathProcessorInterface, OutboundPathProcessorInterface, LanguageSwitcherInterface {


I've tried all sorts of options but can't make it work, and yes, I've cleared caches :-)
Okay, the problem was not in either of these two files.

As suggested by @Berdir I checked the router table and found that my route was not there. However there is nothing wrong with the file.

So the problem must be somewhere else. What if a bad class/method reference could cause this?

As an experiment I replaced the '_form' property with one that was known to work and cleared the caches. Suddenly the route was there in the table.

Checking my Drupal\doublespeak\Form\NegotiationApiUrlForm file I discovered that in my copy/paste haste I hadn't changed the namespace so the form class effectively did not exist. And the route was not loaded into the table.

Fixed. (Phew.)