summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/rest/rest.api.php
blob: d5d1b429f129f15a969fa1f685e0a68319b3f16f (plain) (blame)
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
<?php

/**
 * @file
 * Describes hooks provided by the RESTful Web Services module.
 */

/**
 * @addtogroup hooks
 * @{
 */

/**
 * Alter the resource plugin definitions.
 *
 * @param array $definitions
 *   The collection of resource definitions.
 */
function hook_rest_resource_alter(&$definitions) {
  if (isset($definitions['entity:node'])) {
    // We want to handle REST requests regarding nodes with our own plugin
    // class.
    $definitions['entity:node']['class'] = 'Drupal\my_module\Plugin\rest\resource\NodeResource';
    // Serialized nodes should be expanded to my specific node class.
    $definitions['entity:node']['serialization_class'] = 'Drupal\my_module\Entity\MyNode';
  }
  // We don't want Views to show up in the array of plugins at all.
  unset($definitions['entity:view']);
}

/**
 * @} End of "addtogroup hooks".
 */