Enables the REST service interface for a specific entity type.
string|FALSE $resource_type: The resource type that should get REST API enabled or FALSE to disable all resource types.
string $method: The HTTP method to enable, e.g. GET, POST etc.
string $format: (Optional) The serialization format, e.g. hal_json.
protected function enableService($resource_type, $method = 'GET', $format = NULL) {
// Enable REST API for this entity type.
$config = config('rest.settings');
$settings = array();
if ($resource_type) {
if ($format) {
$settings[$resource_type][$method][$format] = 'TRUE';
}
else {
$settings[$resource_type][$method] = array();
}
}
$config
->set('resources', $settings);
$config
->save();
// Rebuild routing cache, so that the REST API paths are available.
drupal_container()
->get('router.builder')
->rebuild();
// Reset the Simpletest permission cache, so that the new resource
// permissions get picked up.
drupal_static_reset('checkPermissions');
}