Problem/Motivation

Testing whether some rest endpoint work we ran into empty result for at least

curl --verbose --user admin:admin --header 'Accept: application/json' --request GET http://drupal.d8/taxonomy_vocabulary/term/1
{}

Running script drush @drupal.d8 php-script routes.php or inspect the route tabel

// route.php
$routes = db_query('select * from router');
foreach($routes as $route) {
  $route->route = unserialize($route->route);

  if (strpos($route->name, 'rest') !== 0) continue;

  echo "$route->name\t$route->path" . PHP_EOL;
  print_r($route);
}

shows the _content is replaced from [_controller] => Drupal\rest\RequestHandler::handle to [_content] => Drupal\views\Routing\ViewPageController::handle

stdClass Object
(
    [name] => rest.entity.taxonomy_term.GET.json
    [path] => /taxonomy/term/{taxonomy_term}
    [pattern_outline] => /taxonomy/term/%
    [fit] => 6
    [route] => Symfony\Component\Routing\Route Object
        (
            [path:Symfony\Component\Routing\Route:private] => /taxonomy/term/{taxonomy_term}
            [host:Symfony\Component\Routing\Route:private] =>
            [schemes:Symfony\Component\Routing\Route:private] => Array
                (
                )

            [methods:Symfony\Component\Routing\Route:private] => Array
                (
                )

            [defaults:Symfony\Component\Routing\Route:private] => Array
                (
                    [view_id] => taxonomy_term
                    [display_id] => page_1
                    [_content] => Drupal\views\Routing\ViewPageController::handle
                )

            [requirements:Symfony\Component\Routing\Route:private] => Array
                (
                    [_access] => TRUE
                )

            [options:Symfony\Component\Routing\Route:private] => Array
                (
                    [compiler_class] => \Drupal\Core\Routing\RouteCompiler
                    [_access_mode] => ANY
                    [_view_argument_map] => Array
                        (
                            [arg_0] => taxonomy_term
                        )

                    [parameters] => Array
                        (
                            [taxonomy_term] => Array
                                (
                                    [type] => entity:taxonomy_term
                                    [converter] => paramconverter.entity
                                )

                        )
class \Drupal\views\EventSubscriber\RouteSubscriber
...
  protected function alterRoutes(RouteCollection $collection) {

is in error assuming it should take over the json response. But the current view does not have a 'Rest export' display.

Proposed resolution

Remaining tasks

User interface changes

API changes

CommentFileSizeAuthor
#2 view_rest-2344129-2.patch14.26 KBdawehner
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

I see, so views should take care about the _accept option. Myabe we need some logic to override existing
json ones, in case we provide a rest display.

dawehner’s picture

Status: Active » Needs review
FileSize
14.26 KB

Worked on some patch offline. This should get a regression test as well.

Status: Needs review » Needs work

The last submitted patch, 2: view_rest-2344129-2.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

swentel’s picture