當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CRM_Core_BAO_Setting::getSettingSpecification方法代碼示例

本文整理匯總了PHP中CRM_Core_BAO_Setting::getSettingSpecification方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Core_BAO_Setting::getSettingSpecification方法的具體用法?PHP CRM_Core_BAO_Setting::getSettingSpecification怎麽用?PHP CRM_Core_BAO_Setting::getSettingSpecification使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CRM_Core_BAO_Setting的用法示例。


在下文中一共展示了CRM_Core_BAO_Setting::getSettingSpecification方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: civicrm_api3_setting_getfields

/**
 * Get fields for setting api calls.
 *
 * @param array $params
 *
 * @return array
 */
function civicrm_api3_setting_getfields($params)
{
    if (!empty($params['action']) && strtolower($params['action']) == 'getvalue') {
        $result = array('name' => array('title' => 'name of setting field', 'api.required' => 1, 'type' => CRM_Utils_Type::T_STRING), 'group' => array('api.required' => 0, 'title' => 'Setting Group', 'description' => 'Settings Group. This is required if the setting is not stored in config', 'type' => CRM_Utils_Type::T_STRING));
        return civicrm_api3_create_success($result, $params, 'Setting', 'getfields');
    }
    if (!empty($params['name'])) {
        //am of two minds about special handling for 'name' as opposed to other filters - but is does make most common
        //usage really easy
        $params['filters']['name'] = $params['name'];
    }
    $result = CRM_Core_BAO_Setting::getSettingSpecification(CRM_Utils_Array::value('component_id', $params), CRM_Utils_Array::value('filters', $params, array()), CRM_Utils_Array::value('domain_id', $params, NULL), CRM_Utils_Array::value('profile', $params, NULL));
    // find any supplemental information
    if (!empty($params['action'])) {
        $specFunction = '_civicrm_api3_setting_' . strtolower($params['action']) . '_spec';
        if (function_exists($specFunction)) {
            $specFunction($result);
        }
    }
    return civicrm_api3_create_success($result, $params, 'Setting', 'getfields');
}
開發者ID:kidaa30,項目名稱:yes,代碼行數:28,代碼來源:Setting.php

示例2: civicrm_api3_setting_getoptions

/**
 * Get options for settings.
 *
 * @param array $params
 *
 * @return array
 * @throws \API_Exception
 */
function civicrm_api3_setting_getoptions($params)
{
    $specs = CRM_Core_BAO_Setting::getSettingSpecification();
    if (empty($specs[$params['field']]) || empty($specs[$params['field']]['pseudoconstant'])) {
        throw new API_Exception("The field '" . $params['field'] . "' has no associated option list.");
    }
    $pseudoconstant = $specs[$params['field']]['pseudoconstant'];
    // It would be nice if we could leverage CRM_Core_PseudoConstant::get() somehow,
    // but it's tightly coupled to DAO/field. However, if you really need to support
    // more pseudoconstant types, then probably best to refactor it. For now, KISS.
    if (!empty($pseudoconstant['callback'])) {
        $values = Civi\Core\Resolver::singleton()->call($pseudoconstant['callback'], array());
        return civicrm_api3_create_success($values, $params, 'Setting', 'getoptions');
    }
    throw new API_Exception("The field '" . $params['field'] . "' uses an unsupported option list.");
}
開發者ID:scardinius,項目名稱:civicrm-core,代碼行數:24,代碼來源:Setting.php


注:本文中的CRM_Core_BAO_Setting::getSettingSpecification方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。