forked from RESTful-Drupal/restful
-
Notifications
You must be signed in to change notification settings - Fork 0
/
restful.api.php
42 lines (36 loc) · 1.1 KB
/
restful.api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* @file
* Hooks provided by the RESTful module.
*/
/**
* @addtogroup hooks
* @{
*/
/**
* Allow altering the request before it is processed.
*
* @param \Drupal\restful\Http\RequestInterface $request
* The request object.
*/
function hook_restful_parse_request_alter(\Drupal\restful\Http\RequestInterface &$request) {
// Allow implementor modules to alter the request object.
$request->setApplicationData('csrf_token', 'token');
}
/**
* Allow altering the request before it is processed.
*
* @param \Drupal\restful\Plugin\resource\ResourceInterface &$resource
* The resource object to alter.
*/
function hook_restful_resource_alter(\Drupal\restful\Plugin\resource\ResourceInterface &$resource) {
// Chain a decorator with the passed in resource based on the resource
// annotation definition.
$plugin_definition = $resource->getPluginDefinition();
if (!empty($plugin_definition['renderCache']) && !empty($plugin_definition['renderCache']['render'])) {
$resource = new \Drupal\restful\Plugin\resource\CachedResource($resource);
}
}
/**
* @} End of "addtogroup hooks".
*/