diff --git a/core/modules/rest/lib/Drupal/rest/EventSubscriber/RouteSubscriber.php b/core/modules/rest/lib/Drupal/rest/EventSubscriber/RouteSubscriber.php index 10d4043..ef7933f 100644 --- a/core/modules/rest/lib/Drupal/rest/EventSubscriber/RouteSubscriber.php +++ b/core/modules/rest/lib/Drupal/rest/EventSubscriber/RouteSubscriber.php @@ -6,14 +6,12 @@ namespace Drupal\rest\EventSubscriber; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\Routing\Route; - +use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Routing\RouteBuildEvent; use Drupal\Core\Routing\RoutingEvents; -use Drupal\Core\Config\ConfigFactory; use Drupal\rest\Plugin\Type\ResourcePluginManager; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * Subscriber for REST-style routes. @@ -40,22 +38,19 @@ public function __construct(ResourcePluginManager $manager, ConfigFactory $confi } /** - * Adds a dynamic test route. + * Adds routes to enabled REST resources. * * @param \Drupal\Core\Routing\RouteBuildEvent $event * The route building event. * * @return \Symfony\Component\Routing\RouteCollection - * The route collection that contains the new dynamic route. + * The route collection that contains the new dynamic routes. */ public function dynamicRoutes(RouteBuildEvent $event) { $collection = $event->getRouteCollection(); - // @todo The injected version is not working for some reason. We will - // revisit that later. - //$resources = $this->config->get('rest')->get('resources'); - $resources = config('rest')->get('resources'); + $resources = $this->config->get('rest')->load()->get('resources'); if ($resources && $enabled = array_intersect_key($this->manager->getDefinitions(), $resources)) { foreach ($enabled as $key => $resource) { $plugin = $this->manager->getInstance(array('id' => $key)); diff --git a/core/modules/rest/lib/Drupal/rest/Tests/DBLogTest.php b/core/modules/rest/lib/Drupal/rest/Tests/DBLogTest.php index 83e2afe..6bd8e65 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/DBLogTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/DBLogTest.php @@ -52,16 +52,12 @@ public function testWatchdog() { // Write a log message to the DB. watchdog('rest_test', 'Test message'); // Get ID of the written message. - /* $result = db_select('watchdog', 'w') ->condition('type', 'rest_test') ->fields('w', array('wid')) ->execute() ->fetchCol(); $id = $result[0]; - */ - - $id = db_query_range("SELECT wid FROM {watchdog} WHERE type = :type ORDER BY wid DESC", 0, 1, array(':type' => 'rest_test'))->fetchField(); // Create a user account that has the required permissions to read // the watchdog resource via the web API. diff --git a/core/modules/rest/rest.module b/core/modules/rest/rest.module index a020845..b5594fe 100644 --- a/core/modules/rest/rest.module +++ b/core/modules/rest/rest.module @@ -5,9 +5,6 @@ * RESTful web services module. */ -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; - /** * Implements hook_menu(). * @@ -27,32 +24,6 @@ function rest_menu() { } /** - * Implements hook_route_info(). - */ -function rest_route_info() { - $collection = new RouteCollection(); - - // This hook is called during module enabling where the manager has not been - // registered as service yet. - if (drupal_container()->has('plugin.manager.rest')) { - $manager = drupal_container()->get('plugin.manager.rest'); - $resources = config('rest')->get('resources'); - if ($resources && $enabled = array_intersect_key($manager->getDefinitions(), $resources)) { - foreach ($enabled as $key => $resource) { - $plugin = $manager->getInstance(array('id' => $key)); - - // @todo Switch to ->addCollection() once http://drupal.org/node/1819018 is resolved. - foreach ($plugin->routes() as $name => $route) { - $collection->add("rest.$name", $route); - } - } - } - } - - return $collection; -} - -/** * Implements hook_permission(). */ function rest_permission() {