core/modules/rest/src/Routing/ResourceRoutes.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/modules/rest/src/Routing/ResourceRoutes.php b/core/modules/rest/src/Routing/ResourceRoutes.php index 84e0797..1589bf4 100644 --- a/core/modules/rest/src/Routing/ResourceRoutes.php +++ b/core/modules/rest/src/Routing/ResourceRoutes.php @@ -64,8 +64,15 @@ public function __construct(ResourcePluginManager $manager, ConfigFactoryInterfa */ protected function alterRoutes(RouteCollection $collection) { $routes = array(); + + // Silently ignore resources that are in the settings but are not defined on + // the plugin manager currently. That avoids exceptions when REST module is + // enabled before another module that provides the resource plugin specified + // in the settings. + // @todo Remove in https://www.drupal.org/node/2308745 $resources = $this->config->get('rest.settings')->get('resources') ?: array(); $enabled_resources = array_intersect_key($resources, $this->manager->getDefinitions()); + // Iterate over all enabled resource plugins. foreach ($enabled_resources as $id => $enabled_methods) { $plugin = $this->manager->getInstance(array('id' => $id));