You are here

function _civicrm_entity_get_entity_name_from_camel in CiviCRM Entity 7

Same name and namespace in other branches
  1. 7.2 civicrm_entity.module \_civicrm_entity_get_entity_name_from_camel()

Convert possibly camel name to underscore separated entity name.

@TODO Why don't we just call the above function directly? Because the function is officially 'likely' to change as it is an internal api function and calling api functions directly is explicitly not supported

Parameters

string $entity: Entity name in various formats e.g: Contribution => contribution, OptionValue => option_value, UFJoin => uf_join.

Return value

string $entity entity name in underscore separated format

See also

_civicrm_api_get_entity_name_from_camel()

1 call to _civicrm_entity_get_entity_name_from_camel()
civicrm_entity_civicrm_post in ./civicrm_entity.module
Implement the post hook and fire the corresponding rules event.

File

./civicrm_entity.module, line 944
Implement CiviCRM entities as a Drupal Entity.

Code

function _civicrm_entity_get_entity_name_from_camel($entity) {
  if ($entity == strtolower($entity)) {
    return $entity;
  }
  else {
    $entity = ltrim(strtolower(str_replace('U_F', 'uf', preg_replace('/(?=[A-Z])/', '_$0', $entity))), '_');
  }
  return $entity;
}