Commit | Line | Data |
---|---|---|
8e6001d9 | 1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
a30c801b | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
8e6001d9 | 5 | | | |
a30c801b TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
8e6001d9 | 9 | +--------------------------------------------------------------------+ |
10 | */ | |
11 | ||
12 | /** | |
13 | * @package CiviCRM_APIv3 | |
14 | */ | |
15 | ||
16 | /** | |
17 | * Generic api wrapper used to get all unique fields for a given entity. | |
18 | * | |
19 | * @param array $apiRequest | |
20 | * | |
21 | * @return mixed | |
22 | */ | |
445eab89 | 23 | function civicrm_api3_generic_getunique($apiRequest) { |
8e6001d9 | 24 | $entity = _civicrm_api_get_entity_name_from_camel($apiRequest['entity']); |
cf8f0fff | 25 | $uniqueFields = []; |
8e6001d9 | 26 | |
5f262bb2 | 27 | $dao = _civicrm_api3_get_DAO($entity); |
28 | $uFields = $dao::indices(); | |
8e6001d9 | 29 | |
2a7d2b9c TO |
30 | foreach ($uFields as $fieldKey => $field) { |
31 | if (!isset($field['unique']) || !$field['unique']) { | |
5f262bb2 | 32 | continue; |
33 | } | |
34 | $uniqueFields[$fieldKey] = $field['field']; | |
8e6001d9 | 35 | } |
36 | ||
37 | return civicrm_api3_create_success($uniqueFields); | |
38 | } |