Skip to content

Commit ebfbca2

Browse files
author
Mateu Aguiló Bosch
committed
[BUGFIX] Revert plugin massaging
It was done elsewhere.
1 parent 8c0842b commit ebfbca2

File tree

1 file changed

+19
-28
lines changed

1 file changed

+19
-28
lines changed

src/Resource/ResourceManager.php

+19-28
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,31 @@ public function getPlugins($only_enabled = TRUE) {
8484
* {@inheritdoc}
8585
*/
8686
public function getPlugin($instance_id, RequestInterface $request = NULL) {
87-
return $this->massagePlugin($this->plugins->get($instance_id), $request);
87+
/* @var ResourceInterface $plugin */
88+
if (!$plugin = $this->plugins->get($instance_id)) {
89+
return NULL;
90+
}
91+
if ($request) {
92+
$plugin->setRequest($request);
93+
}
94+
return $plugin;
8895
}
8996

9097
/**
9198
* {@inheritdoc}
9299
*/
93100
public function getPluginCopy($instance_id, RequestInterface $request = NULL) {
94-
return $this->massagePlugin($this->pluginManager->createInstance($instance_id), $request);
101+
if (!$plugin = $this->pluginManager->createInstance($instance_id)) {
102+
return NULL;
103+
}
104+
if ($request) {
105+
$plugin->setRequest($request);
106+
}
107+
// Allow altering the resource, this way we can read the resource's
108+
// definition to return a different class that is using composition.
109+
drupal_alter('restful_resource', $plugin);
110+
$plugin = $plugin->isEnabled() ? $plugin : NULL;
111+
return $plugin;
95112
}
96113

97114
/**
@@ -318,30 +335,4 @@ public function getResourceLastVersion($resource_name, $major_version = NULL) {
318335
return array($resource['majorVersion'], $resource['minorVersion']);
319336
}
320337

321-
/**
322-
* Helper method that sets the request and alters the resource.
323-
*
324-
* @param ResourceInterface $plugin
325-
* The resource to return.
326-
* @param RequestInterface $request
327-
* The request.
328-
*
329-
* @return ResourceInterface
330-
* The transformed resource.
331-
*/
332-
protected function massagePlugin(ResourceInterface $plugin = NULL, RequestInterface $request = NULL) {
333-
if (!$plugin) {
334-
return NULL;
335-
}
336-
if ($request) {
337-
$plugin->setRequest($request);
338-
}
339-
// Allow altering the resource, this way we can read the resource's
340-
// definition to return a different class that is using composition.
341-
drupal_alter('restful_resource', $plugin);
342-
$plugin = $plugin->isEnabled() ? $plugin : NULL;
343-
344-
return $plugin;
345-
}
346-
347338
}

0 commit comments

Comments
 (0)