Drupal 7 Services -- hook_services_request_postprocess_alter() does not identify the requested resource According to the Services API in Drupal 7, we can use hook_services_request_postprocess_alter() to alter drupal's REST response before returning it to the user. This is useful if you want to alter the structure of an array, or strip out data we don't want returned to the API user. However, I don't see any way to identify what resource is being requested explicitly.

The Hooks passes: ($controller, $args, &amp;$result);

The controller has semi-identifiable information, such as the callback which was fired, or the file where this resource exists. For instance, when firing a node INDEX request, we'd see:

[help] =&gt; List all nodes
[file] =&gt; Array
    (
        [type] =&gt; inc
        [module] =&gt; services
        [name] =&gt; resources/node_resource
    )

[callback] =&gt; _node_resource_index
[args] =&gt; Array
    (
        [0] =&gt; Array
            (
                [name] =&gt; page
                [optional] =&gt; 1
                [type] =&gt; int
                [description] =&gt; The zero-based index of the page to get, defaults to 0.
                [default value] =&gt; 0
                [source] =&gt; Array
                    (
                        [param] =&gt; page
                    )

            )


Etc. However, there is nothing standard here across services which would tell us: "This is a node INDEX request, using the NODE endpoint." 

To be clear, we're referring to node in the resource sense, such as my_host/my_endpoint/node.json. Meaning, which of our endpoint's resources is being requested here, and what (if any) method/operation are we performing.

I was hoping there was something standard within this hook to identify this information, as opposed to relying on more external data, such as the GET or POST variables.

Anyone have insight into this?



[edit]: 

hook_services_request_preprocess_alter() is passed an $options array, which contains the endpoint resource and method. I need access to this information in the postprocess hook mentioned above, but don't see any clean, Drupal-way to do that. this is what I am looking for.

The array looks as follows:

Array(
  [version] =&gt; ,
  [resource] =&gt; node, 
  [method] =&gt; 1.json
);
if you take a look to $args array, you can find your node type, for example I have a content type "video", my $args are like this:

Array
(
    [0] =&gt; 2
    [1] =&gt; *
    [2] =&gt; Array
        (
            [type] =&gt; video
            [uid] =&gt; 92
        )

    [3] =&gt; 2
)


Then $args[2] has the content type (because I set it like a parameter in my resource:
http://site.local/api/v1/node?parameters[type]=video&amp;parameters[uid]=92&amp;pagesize=2&amp;page=2