You are here

function restful_token_auth_restful_resource_alter in RESTful 7.2

Implements hook_restful_resource_alter().

File

modules/restful_token_auth/restful_token_auth.module, line 115
RESTful token authentication.

Code

function restful_token_auth_restful_resource_alter(ResourceInterface &$resource) {
  $plugin_definition = $resource
    ->getPluginDefinition();
  if (empty($plugin_definition['dataProvider']['entityType']) || $plugin_definition['dataProvider']['entityType'] != 'restful_token_auth' || !empty($plugin_definition['formatter'])) {
    return;
  }

  // If this resource is based on access token entities and does not have an
  // explicit formatter attached to it, then use the single_json formatter.
  $plugin_definition['formatter'] = 'single_json';
  $resource
    ->setPluginDefinition($plugin_definition);
}