Issue #2579235 by kylebrowning, willzyx: Resource plugin manager needlessly calls wrong method to instantiate plugins
parent
df74821d4e
commit
e039fa2dac
|
@ -36,6 +36,10 @@ class ResourcePluginManager extends DefaultPluginManager {
|
|||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @deprecated in Drupal 8.2.0.
|
||||
* Use Drupal\rest\Plugin\Type\ResourcePluginManager::createInstance()
|
||||
* instead.
|
||||
*/
|
||||
public function getInstance(array $options){
|
||||
if (isset($options['id'])) {
|
||||
|
|
|
@ -38,7 +38,7 @@ class RequestHandler implements ContainerAwareInterface {
|
|||
|
||||
$resource = $this->container
|
||||
->get('plugin.manager.rest')
|
||||
->getInstance(array('id' => $plugin));
|
||||
->createInstance($plugin);
|
||||
|
||||
// Deserialize incoming data if available.
|
||||
$serializer = $this->container->get('serializer');
|
||||
|
|
|
@ -55,8 +55,8 @@ class RestPermissions implements ContainerInjectionInterface {
|
|||
$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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,8 +73,7 @@ class ResourceRoutes extends RouteSubscriberBase {
|
|||
|
||||
// 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();
|
||||
|
|
|
@ -55,7 +55,7 @@ class RequestHandlerTest extends KernelTestBase {
|
|||
|
||||
// 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 @@ class RequestHandlerTest extends KernelTestBase {
|
|||
|
||||
// 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());
|
||||
|
||||
|
|
Loading…
Reference in New Issue