Commit e039fa2d authored by catch's avatar catch

Issue #2579235 by kylebrowning, willzyx: Resource plugin manager needlessly...

Issue #2579235 by kylebrowning, willzyx: Resource plugin manager needlessly calls wrong method to instantiate plugins
parent df74821d
......@@ -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'])) {
......
......@@ -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');
......
......@@ -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());
}
}
......
......@@ -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();
......
......@@ -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());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment