diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php b/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php index 35be5df..829013f 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php @@ -62,11 +62,8 @@ public function routes() { $prefix = strtr($this->plugin_id, ':', '/'); $route = new Route("/$prefix/{id}", array( '_controller' => 'Drupal\rest\RequestHandler::handle', - // @todo Once http://drupal.org/node/1793520 is committed we will have - // route object avaialble in the controller so 'plugin' property - // should be changed to '_plugin'. - // @see RequestHandler::handle(). - 'plugin' => $this->plugin_id, + // Pass the resource plugin ID along as default property. + '_plugin' => $this->plugin_id, ), array( // The HTTP method is a requirement for this route. '_method' => $method, diff --git a/core/modules/rest/lib/Drupal/rest/RequestHandler.php b/core/modules/rest/lib/Drupal/rest/RequestHandler.php index f30684d..53011cf 100644 --- a/core/modules/rest/lib/Drupal/rest/RequestHandler.php +++ b/core/modules/rest/lib/Drupal/rest/RequestHandler.php @@ -20,19 +20,16 @@ class RequestHandler extends ContainerAware { /** * Handles a web API request. * - * @param string $plugin - * The resource type plugin. * @param Symfony\Component\HttpFoundation\Request $request * The HTTP request object. * @param mixed $id * The resource ID. * - * @todo Remove $plugin as argument. After http://drupal.org/node/1793520 is - * committed we would be able to access route object as - * $request->attributes->get('_route'). Then we will get plugin as - * '_plugin' property of route object. + * @return \Symfony\Component\HttpFoundation\Response + * The response object. */ - public function handle($plugin, Request $request, $id = NULL) { + public function handle(Request $request, $id = NULL) { + $plugin = $request->attributes->get('_route')->getDefault('_plugin'); $method = strtolower($request->getMethod()); $resource = $this->container ->get('plugin.manager.rest')