Gizra/restful — pull request #302 by mateu-aguilo-bosch (2014-12-09 10:41:31+00:00)
Title: Allow rendering entities providing a view mode.

The idea is to leverage Drupal's configuration capabilities to specify which fields to render and how to render them using the field formatters.

I think it's *great* to have the fine grain control that we have now on how to build the output, but we're core missing a lot from Drupal core by not using the entity view modes.

## Goals:
* Minimal configuration. Probably without even needing a custom class that extends from `RestfulNodeBase`, `RestfulEntityBase`, …
* Generating the **exact** desired output **without code**.
* The only rendering limitations should be those inherited from rendering a view mode.

## Suggested approach:
* Provide a `'view_mode'` configuration key in the plugin definition.
* Provide a mapping config array between the keys in the rendered view mode and the desired output.
- This mapping would be a replace for the default field info method, from there on everything else should be **the same** from the implementation standpoint.
- This mapping should be seen as plugin configuration, not as code.
- This mapping should allow path nesting. This of a view mode that has an ER field and renders the referenced entity with only its body. We would do `'field_referenced_node' => 'referenced::body::value'`. That could yield:
```javascript
{
"referenced": {
"body": {
"value": "Lorem ipsum dolor…"
}
}
}
```