当前位置: 首页>>代码示例>>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;未经允许,请勿转载。