Problem/Motivation

Currently the menu resource does not provide enough information to construct a new representation of the menu in a decoupled environment. Any links contained within that menu are not represented within the response.

Proposed resolution

TBD

Remaining tasks

TBD

User interface changes

TBd

API changes

TBD

Data model changes

TBD

Comments

Wim Leers created an issue. See original summary.

Wim Leers’s picture

Issue summary: View changes
Wim Leers’s picture

Issue summary: View changes
dawehner’s picture

Agreed that this is useful. I'm wondering whether we should expose the tree structure or flatten it and let the client deal with the hierarchy.
On top of that I'm wondering whether there are best practises around exposing hierarchical structures in general.

Wim Leers’s picture

#4: great questions!

drpal’s picture

Issue summary: View changes
drpal’s picture

I think exposing the tree structure makes the most sense, it puts the effort of reconstruction on the client, and we also aren't forcing something on them. Possibly something like the following?

{
  ... 
  "items": [{
    "title": "Contact Us",
    "href": "http://mysite.dev/contact",
    "weight": "-50",
    "depth": "1",
    "children": [{
      "title": "Phone",
      "href": "http://mysite.dev/contact/phone",
      "weight": "1",
      "depth": "2",
      "children": []
    }]
  }]
}

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Wim Leers’s picture

Apparently there is a contrib module that provides this: https://www.drupal.org/project/rest_menu_tree.

Wim Leers’s picture

Status: Active » Postponed

And there's also https://www.drupal.org/project/rest_menu_items, which appears to be more popular and more complete.

Since there are 2 options in contrib, marking this as postponed. It's probably better to let this mature in contrib first.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.