You are here

protected function ServicesClientUUIDResourceController::normalizeEntityId in Services Client 7.2

Normalize entity id, if in UUID format, convert to local id.

Parameters

string $entity_type: Entity type.

string $entity_id: Entity id.

Return value

int Local entity id.

4 calls to ServicesClientUUIDResourceController::normalizeEntityId()
ServicesClientUUIDResourceController::access in services_client_services/includes/ServicesClientUUIDResourceController.inc
Implements ServicesResourceControllerInterface::access().
ServicesClientUUIDResourceController::delete in services_client_services/includes/ServicesClientUUIDResourceController.inc
Implements ServicesResourceControllerInterface::delete().
ServicesClientUUIDResourceController::retrieve in services_client_services/includes/ServicesClientUUIDResourceController.inc
Implements ServicesResourceControllerInterface::retrieve().
ServicesClientUUIDResourceController::update in services_client_services/includes/ServicesClientUUIDResourceController.inc
Implements ServicesResourceControllerInterface::update().

File

services_client_services/includes/ServicesClientUUIDResourceController.inc, line 151
Custom controller to allow handling requests with UUIDs.

Class

ServicesClientUUIDResourceController
@file Custom controller to allow handling requests with UUIDs.

Code

protected function normalizeEntityId($entity_type, $entity_id) {
  if ($this
    ->validUUID($entity_id)) {
    if (function_exists('uuid_find')) {
      $info = entity_get_info($entity_type);
      $entity_id = uuid_find($entity_id, $info['base table'], $info['entity keys']['id'], 'uuid');
    }
    else {
      $result = entity_get_id_by_uuid($entity_type, array(
        $entity_id,
      ));
      $entity_id = reset($result);
    }
  }
  return $entity_id;
}