2
votes

I am creating two custom content type with reference to these pages:

https://www.drupal.org/node/2629550

https://www.drupal.org/node/2693979

Uncaught PHP Exception Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: "You have requested a non-existent service "router.route_provider.old". Did you mean one of these: "router.route_provider", "router.route_preloader"?" at ...\core\lib\Drupal\Component\DependencyInjection\Container.php line 157

Could anyone please help me, why this is happening and how to fix it ?

I am using Drupal 8.1.8 version.

1
Can you edit your question to include the code around line 52 of DiscoveryTrait.php?Jon Peterson
Here is the code around 52: protected function doGetDefinition(array $definitions, $plugin_id, $exception_on_invalid) { // Avoid using a ternary that would create a copy of the array. if (isset($definitions[$plugin_id])) { return $definitions[$plugin_id]; } elseif (!$exception_on_invalid) { return NULL; } throw new PluginNotFoundException($plugin_id, sprintf('The "%s" plugin does not exist.', $plugin_id)); }Md. Shafiq Hossain
That is very hard to read and people may not see that here in the comments. Please edit your question to include that. I know nothing about Drupal, just trying to help you get your question answered.Jon Peterson
api.drupal.org/api/drupal/… see function name : doGetDefinition() where it throws the errorMd. Shafiq Hossain

1 Answers

3
votes

I checked in core.services.yml file, there is no route declared as "router.route_provider.old"

I have created a router names as "router.route_provider.old" by copying "router.route_provider" in the core.services.yml file, which solves my problem.

i think Drupal uses "router.route_provider.old" router as a temporary to copy "router.route_provider" router info. But as this router name is not exists, its throwing exception.

I don't know if this is a bug or there is better way to fix it.

Update: A patch is provided here: https://www.drupal.org/node/2788087