diff --git a/core/includes/module.inc b/core/includes/module.inc index abe03dd..9be96cd 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -493,6 +493,7 @@ function module_enable($module_list, $enable_dependencies = TRUE) { $schema_store = drupal_container()->get('keyvalue')->get('system.schema'); $module_config = config('system.module'); $disabled_config = config('system.module.disabled'); + $module_filenames = drupal_container()->getParameter('container.modules'); foreach ($module_list as $module) { // Only process modules that are not already enabled. $enabled = $module_config->get("enabled.$module") !== NULL; @@ -516,11 +517,12 @@ function module_enable($module_list, $enable_dependencies = TRUE) { system_list_reset(); module_implements_reset(); _system_update_bootstrap_status(); + $module_filenames[$module] = drupal_get_filename('module', $module); // Update the kernel to include it. // @todo The if statement is here because install_begin_request() creates // a container without a kernel. It probably shouldn't. if ($kernel = drupal_container()->get('kernel', ContainerInterface::NULL_ON_INVALID_REFERENCE)) { - $kernel->updateModules(module_list(), array($module => drupal_get_filename('module', $module))); + $kernel->updateModules(module_list(), $module_filenames); } // Refresh the schema to include it. drupal_get_schema(NULL, TRUE); diff --git a/core/modules/jsonld/lib/Drupal/jsonld/EventSubscriber/JsonldSubscriber.php b/core/modules/jsonld/lib/Drupal/jsonld/EventSubscriber/JsonldSubscriber.php index f764bea..38a06ec 100644 --- a/core/modules/jsonld/lib/Drupal/jsonld/EventSubscriber/JsonldSubscriber.php +++ b/core/modules/jsonld/lib/Drupal/jsonld/EventSubscriber/JsonldSubscriber.php @@ -23,8 +23,9 @@ class JsonldSubscriber implements EventSubscriberInterface { * The event to process. */ public function onKernelRequest(GetResponseEvent $event) { - $event->getRequest()->setFormat('drupal_jsonld', 'application/vnd.drupal.ld+json'); - $event->getRequest()->setFormat('jsonld', 'application/ld+json'); + $request = $event->getRequest(); + $request->setFormat('drupal_jsonld', 'application/vnd.drupal.ld+json'); + $request->setFormat('jsonld', 'application/ld+json'); } /** diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php b/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php index efef44d..018d592 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/ResourceBase.php @@ -61,38 +61,20 @@ public function routes() { $lower_method = strtolower($method); // Only expose routes where the HTTP request method exists on the plugin. if (method_exists($this, $lower_method)) { - // Restrict GET and HEAD requests to the media type specified in the - // HTTP Accept headers. + $route = new Route("/$prefix/{id}", array( + '_controller' => 'Drupal\rest\RequestHandler::handle', + // 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, + '_permission' => "restful $lower_method $this->plugin_id", + )); + if ($method == 'GET' || $method == 'HEAD') { - $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, - ), array( - // The HTTP method is a requirement for this route. - '_method' => $method, - '_permission' => "restful $lower_method $this->plugin_id", - // The media type format is a requirement, too. - // @todo Replace hard coded format here with available formats. - '_format' => 'drupal_jsonld', - )); - } - else { - $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, - ), array( - // The HTTP method is a requirement for this route. - '_method' => $method, - '_permission' => "restful $lower_method $this->plugin_id", - )); + // Restrict GET and HEAD requests to the media type specified in the + // HTTP Accept headers. + $route->addRequirements(array('_format' => 'drupal_jsonld')); } $collection->add("$name.$method", $route); }