diff --git a/core/modules/rest/src/Entity/RestResourceConfig.php b/core/modules/rest/src/Entity/RestResourceConfig.php index 3e0e75f..8d24af4 100644 --- a/core/modules/rest/src/Entity/RestResourceConfig.php +++ b/core/modules/rest/src/Entity/RestResourceConfig.php @@ -50,9 +50,9 @@ class RestResourceConfig extends ConfigEntityBase implements RestResourceConfigI protected $configuration; /** - * The plugin manager used by this entity type. + * The rest resource plugin manager. * - * @var \Drupal\Component\Plugin\PluginManagerBase + * @var \Drupal\Component\Plugin\PluginManagerInterface */ protected $pluginManager; @@ -75,12 +75,24 @@ public function __construct(array $values, $entity_type) { * @return string The label. */ protected function getLabelFromPlugin() { - $plugin_definition = $this->pluginManager + $plugin_definition = $this->getResourcePluginManager() ->getDefinition(['id' => $this->getResourcePluginID()]); return $plugin_definition['label']; } /** + * Returns the resource plugin manager. + * + * @return \Drupal\Component\Plugin\PluginManagerInterface + */ + protected function getResourcePluginManager() { + if (!isset($this->pluginManager)) { + $this->pluginManager = \Drupal::service('plugin.manager.rest'); + } + return $this->pluginManager; + } + + /** * {@inheritdoc} */ public function getResourcePluginID() { @@ -233,7 +245,7 @@ public function removeSupportedFormat($method, $format) { */ public function getPluginCollections() { return [ - 'resource' => new DefaultSingleLazyPluginCollection($this->pluginManager, $this->getResourcePluginID(), []) + 'resource' => new DefaultSingleLazyPluginCollection($this->getResourcePluginManager(), $this->getResourcePluginID(), []) ]; } diff --git a/core/modules/rest/src/Routing/ResourceRoutes.php b/core/modules/rest/src/Routing/ResourceRoutes.php index b218119..b0a405b 100644 --- a/core/modules/rest/src/Routing/ResourceRoutes.php +++ b/core/modules/rest/src/Routing/ResourceRoutes.php @@ -115,6 +115,7 @@ protected function getRoutesForResourceConfig(RestResourceConfigInterface $rest_ // The configuration seems legit at this point, so we set the // authentication provider and add the route. $route->setOption('_auth', $rest_resource_config->getSupportedAuthenticationProviders($method)); + $route->setDefault('_rest_resource_config', $rest_resource_config->id()); $collection->add("rest.$name", $route); }