diff --git a/core/modules/rest/src/Plugin/Type/ResourcePluginManager.php b/core/modules/rest/src/Plugin/Type/ResourcePluginManager.php index 9a3587c4427ca211e9aa56fef4f9fd3330bf8e2f..4aa46b209f665f54f2a4a48dc04c619d33650d9a 100644 --- a/core/modules/rest/src/Plugin/Type/ResourcePluginManager.php +++ b/core/modules/rest/src/Plugin/Type/ResourcePluginManager.php @@ -36,6 +36,10 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac /** * {@inheritdoc} + * + * @deprecated in Drupal 8.2.0. + * Use Drupal\rest\Plugin\Type\ResourcePluginManager::createInstance() + * instead. */ public function getInstance(array $options){ if (isset($options['id'])) { diff --git a/core/modules/rest/src/RequestHandler.php b/core/modules/rest/src/RequestHandler.php index 4ccc6ac35254c43f3e5b66bf388e81fac6aa8d07..8e0cd74ee69eafd2838c621f5c3c0071d78d9500 100644 --- a/core/modules/rest/src/RequestHandler.php +++ b/core/modules/rest/src/RequestHandler.php @@ -38,7 +38,7 @@ public function handle(RouteMatchInterface $route_match, Request $request) { $resource = $this->container ->get('plugin.manager.rest') - ->getInstance(array('id' => $plugin)); + ->createInstance($plugin); // Deserialize incoming data if available. $serializer = $this->container->get('serializer'); diff --git a/core/modules/rest/src/RestPermissions.php b/core/modules/rest/src/RestPermissions.php index 5733ef2276b817621c4384d02ca834ea21207fca..57e95e4da427ab56e46d65617d427ab09ae9f020 100644 --- a/core/modules/rest/src/RestPermissions.php +++ b/core/modules/rest/src/RestPermissions.php @@ -55,8 +55,8 @@ public function permissions() { $permissions = []; $resources = $this->configFactory->get('rest.settings')->get('resources'); if ($resources && $enabled = array_intersect_key($this->restPluginManager->getDefinitions(), $resources)) { - foreach ($enabled as $key => $resource) { - $plugin = $this->restPluginManager->getInstance(['id' => $key]); + foreach ($enabled as $id => $resource) { + $plugin = $this->restPluginManager->createInstance($id); $permissions = array_merge($permissions, $plugin->permissions()); } } diff --git a/core/modules/rest/src/Routing/ResourceRoutes.php b/core/modules/rest/src/Routing/ResourceRoutes.php index fc72150fe538aa93957b63c36169d1a23ed591c8..e88f18be32f19c2f671c023ffcf0506349dcab17 100644 --- a/core/modules/rest/src/Routing/ResourceRoutes.php +++ b/core/modules/rest/src/Routing/ResourceRoutes.php @@ -73,8 +73,7 @@ protected function alterRoutes(RouteCollection $collection) { // Iterate over all enabled resource plugins. foreach ($enabled_resources as $id => $enabled_methods) { - $plugin = $this->manager->getInstance(array('id' => $id)); - + $plugin = $this->manager->createInstance($id); foreach ($plugin->routes() as $name => $route) { // @todo: Are multiple methods possible here? $methods = $route->getMethods(); diff --git a/core/modules/rest/tests/src/Kernel/RequestHandlerTest.php b/core/modules/rest/tests/src/Kernel/RequestHandlerTest.php index 6c19ca4b376a06b82ae0cf0a5179dc0ed95c9a7d..36a482cd232ef687fd06b3572faa43953a270dc0 100644 --- a/core/modules/rest/tests/src/Kernel/RequestHandlerTest.php +++ b/core/modules/rest/tests/src/Kernel/RequestHandlerTest.php @@ -55,7 +55,7 @@ public function testBaseHandler() { // Setup stub plugin manager that will return our plugin. $stub = $this->prophesize(ResourcePluginManager::class); - $stub->getInstance(['id' => 'restplugin']) + $stub->createInstance('restplugin') ->willReturn($resource->reveal()); $this->container->set('plugin.manager.rest', $stub->reveal()); @@ -95,7 +95,7 @@ public function testSerialization($data) { // Setup stub plugin manager that will return our plugin. $stub = $this->prophesize(ResourcePluginManager::class); - $stub->getInstance(['id' => 'restplugin']) + $stub->createInstance('restplugin') ->willReturn($resource->reveal()); $this->container->set('plugin.manager.rest', $stub->reveal());