Merge pull request #6332 from colemanw/CRM-11856
[civicrm-core.git] / api / api.php
index 6c263513e871deca72176ac02f4b600bda8b387c..4f53c542fc0324b54e6361ee65a70ba28f963cc5 100644 (file)
@@ -1,14 +1,9 @@
 <?php
 
 /**
- * @file
- * File for the CiviCRM APIv3 API wrapper.
+ * @file CiviCRM APIv3 API wrapper.
  *
  * @package CiviCRM_APIv3
- * @subpackage API
- *
- * @copyright CiviCRM LLC (c) 2004-2014
- * @version $Id: api.php 30486 2010-11-02 16:12:09Z shot $
  */
 
 /**
@@ -82,7 +77,7 @@ function _civicrm_api3_api_getfields(&$apiRequest) {
   }
   $getFieldsParams = array('action' => $apiRequest['action']);
   $entity = $apiRequest['entity'];
-  if ($entity == 'profile' && array_key_exists('profile_id', $apiRequest['params'])) {
+  if ($entity == 'Profile' && array_key_exists('profile_id', $apiRequest['params'])) {
     $getFieldsParams['profile_id'] = $apiRequest['params']['profile_id'];
   }
   $fields = civicrm_api3($entity, 'getfields', $getFieldsParams);
@@ -110,14 +105,14 @@ function civicrm_error($result) {
 }
 
 /**
- * Get camel case version of entity or action name.
+ * Get camel case version of entity name.
  *
- * @param $entity
+ * @param string|null $entity
  *
- * @return string
+ * @return string|null
  */
 function _civicrm_api_get_camel_name($entity) {
-  return CRM_Utils_String::convertStringToCamel($entity);
+  return is_string($entity) ? CRM_Utils_String::convertStringToCamel($entity) : NULL;
 }
 
 /**
@@ -176,11 +171,9 @@ function _civicrm_api_replace_variables(&$params, &$parentResult, $separator = '
  *
  * @return string
  *   Entity name in underscore separated format.
- *
- * @fixme Why isn't this called first thing in civicrm_api wrapper?
  */
 function _civicrm_api_get_entity_name_from_camel($entity) {
-  if ($entity == strtolower($entity)) {
+  if (!$entity || $entity === strtolower($entity)) {
     return $entity;
   }
   else {
@@ -203,5 +196,5 @@ function _civicrm_api_get_entity_name_from_camel($entity) {
  */
 function _civicrm_api_get_entity_name_from_dao($bao) {
   $daoName = str_replace("BAO", "DAO", get_class($bao));
-  return _civicrm_api_get_entity_name_from_camel(CRM_Core_DAO_AllCoreTables::getBriefName($daoName));
+  return CRM_Core_DAO_AllCoreTables::getBriefName($daoName);
 }