Skip to content

When a property isn't available

jeff-h edited this page Sep 9, 2015 · 1 revision

If you need to provide data via your RESTful API using data that is not available to the entity's metadata wrapper, you have two options:

Use hook_entity_property_info

Use hook_entity_property_info so that Drupal knows about the data, as an entity property.

This has the advantage that the property information you are adding will be available not only to RESTful but to your entire app.

Use a callback instead of a property

    $public_fields['available'] = array(
      'callback' => array($this, 'quizAvailability'),
    );

This will provide the extra information to your REST API, but not to anything else in Drupal.

There is a thread relevant to this topic in the issue queue: https://github.com/RESTful-Drupal/restful/issues/353

Clone this wiki locally