You are here

function _services_uuid_resource_retrieve in Services Client 7.2

Same name and namespace in other branches
  1. 7 services_uuid/services_uuid.module \_services_uuid_resource_retrieve()

Function to handle actual retrieval of the xID for the UUID

Parameters

$type:

$uuid:

Return value

int

1 call to _services_uuid_resource_retrieve()
_services_uuid_resource_access in services_uuid/services_uuid.module
Access callback to handle permissions for retrieving UUIDs
1 string reference to '_services_uuid_resource_retrieve'
services_uuid_services_resources in services_uuid/services_uuid.module
Implementation of hook_services_resources() Defines the UUID resource fo the services module

File

services_uuid/services_uuid.module, line 47

Code

function _services_uuid_resource_retrieve($type, $uuid) {

  // Latest version of uuid module (alpha6)
  if (function_exists('entity_get_id_by_uuid')) {
    $ids = entity_get_id_by_uuid($type, array(
      $uuid,
    ));
    return reset($ids);
  }
  else {
    switch ($type) {
      case 'node':
        $nid = uuid_node_find($uuid);
        return $nid;
      case 'user':
        $uid = uuid_user_find($uuid);
        return $uid;
      case 'taxonomy':
        $tid = uuid_taxonomy_term_find($uuid);
        return $tid;
      case 'role':
        $rid = uuid_role_find($uuid);
        return $rid;
      case 'comment':
        $cid = uuid_comment_find($uuid);
        return $cid;
      case 'file':
        $fid = uuid_file_find($uuid);
        return $fid;
      default:
        return services_error(t('Unsupported UUID resource %type type.', array(
          '%type' => $type,
        )), 406);
    }
  }
}