当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_TemporaryErrorScope::create方法代码示例

本文整理汇总了PHP中CRM_Core_TemporaryErrorScope::create方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_TemporaryErrorScope::create方法的具体用法?PHP CRM_Core_TemporaryErrorScope::create怎么用?PHP CRM_Core_TemporaryErrorScope::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_TemporaryErrorScope的用法示例。


在下文中一共展示了CRM_Core_TemporaryErrorScope::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: smarty_function_crmAPI

/**
 * @param $params
 * @param $smarty
 * @return string|void
 */
function smarty_function_crmAPI($params, &$smarty)
{
    if (!array_key_exists('entity', $params)) {
        $smarty->trigger_error("assign: missing 'entity' parameter");
        return "crmAPI: missing 'entity' parameter";
    }
    $errorScope = CRM_Core_TemporaryErrorScope::create(array('CRM_Utils_REST', 'fatal'));
    $entity = $params['entity'];
    $action = CRM_Utils_Array::value('action', $params, 'get');
    $params['sequential'] = CRM_Utils_Array::value('sequential', $params, 1);
    $var = CRM_Utils_Array::value('var', $params);
    CRM_Utils_Array::remove($params, 'entity', 'action', 'var');
    $params['version'] = 3;
    require_once 'api/api.php';
    $result = civicrm_api($entity, $action, $params);
    unset($errorScope);
    if ($result === FALSE) {
        $smarty->trigger_error("Unknown error");
        return;
    }
    if (!empty($result['is_error'])) {
        $smarty->trigger_error("{crmAPI} " . $result["error_message"]);
    }
    if (!$var) {
        return json_encode($result);
    }
    if (!empty($params['json'])) {
        $smarty->assign($var, json_encode($result));
    } else {
        $smarty->assign($var, $result);
    }
}
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:37,代码来源:function.crmAPI.php

示例2: smarty_function_crmSetting

/**
 * Retrieve CiviCRM settings from the api for use in templates.
 *
 * @param $params
 * @param $smarty
 *
 * @return int|string|null
 */
function smarty_function_crmSetting($params, &$smarty)
{
    $errorScope = CRM_Core_TemporaryErrorScope::create(array('CRM_Utils_REST', 'fatal'));
    unset($params['method']);
    unset($params['assign']);
    $params['version'] = 3;
    require_once 'api/api.php';
    $result = civicrm_api('setting', 'getvalue', $params);
    unset($errorScope);
    if ($result === FALSE) {
        $smarty->trigger_error("Unknown error");
        return NULL;
    }
    if (empty($params['var'])) {
        return is_numeric($result) ? $result : json_encode($result);
    }
    if (!empty($params['json'])) {
        $smarty->assign($params["var"], json_encode($result));
    } else {
        $smarty->assign($params["var"], $result);
    }
}
开发者ID:kidaa30,项目名称:yes,代码行数:30,代码来源:function.crmSetting.php

示例3: unset

 /**
  * Singleton function used to manage this object.
  *
  * @param bool $loadFromDB
  *   whether to load from the database.
  * @param bool $force
  *   whether to force a reconstruction.
  *
  * @return CRM_Core_Config
  */
 public static function &singleton($loadFromDB = TRUE, $force = FALSE)
 {
     if (self::$_singleton === NULL || $force) {
         $GLOBALS['civicrm_default_error_scope'] = CRM_Core_TemporaryErrorScope::create(array('CRM_Core_Error', 'handle'));
         $errorScope = CRM_Core_TemporaryErrorScope::create(array('CRM_Core_Error', 'simpleHandler'));
         if (defined('E_DEPRECATED')) {
             error_reporting(error_reporting() & ~E_DEPRECATED);
         }
         self::$_singleton = new CRM_Core_Config();
         \Civi\Core\Container::boot($loadFromDB);
         if ($loadFromDB && self::$_singleton->dsn) {
             $domain = \CRM_Core_BAO_Domain::getDomain();
             \CRM_Core_BAO_ConfigSetting::applyLocale(\Civi::settings($domain->id), $domain->locales);
             unset($errorScope);
             CRM_Utils_Hook::config(self::$_singleton);
             self::$_singleton->authenticate();
             // Extreme backward compat: $config binds to active domain at moment of setup.
             self::$_singleton->getSettings();
             Civi::service('settings_manager')->useDefaults();
         }
     }
     return self::$_singleton;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:33,代码来源:Config.php

示例4: ajaxJson

 /**
  * This is a wrapper so you can call an api via json (it returns json too)
  * http://example.org/civicrm/api/json?entity=Contact&action=Get"&json={"contact_type":"Individual","email.get.email":{}} to take all the emails from individuals
  * works for POST & GET (POST recommended)
  */
 public static function ajaxJson()
 {
     $requestParams = CRM_Utils_Request::exportValues();
     require_once 'api/v3/utils.php';
     // Why is $config undefined -- $config = CRM_Core_Config::singleton();
     if (!$config->debug && (!array_key_exists('HTTP_X_REQUESTED_WITH', $_SERVER) || $_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest")) {
         $error = civicrm_api3_create_error("SECURITY ALERT: Ajax requests can only be issued by javascript clients, eg. CRM.api3().", array('IP' => $_SERVER['REMOTE_ADDR'], 'level' => 'security', 'referer' => $_SERVER['HTTP_REFERER'], 'reason' => 'CSRF suspected'));
         CRM_Utils_JSON::output($error);
     }
     if (empty($requestParams['entity'])) {
         CRM_Utils_JSON::output(civicrm_api3_create_error('missing entity param'));
     }
     if (empty($requestParams['entity'])) {
         CRM_Utils_JSON::output(civicrm_api3_create_error('missing entity entity'));
     }
     if (!empty($requestParams['json'])) {
         $params = json_decode($requestParams['json'], TRUE);
     }
     $entity = CRM_Utils_String::munge(CRM_Utils_Array::value('entity', $requestParams));
     $action = CRM_Utils_String::munge(CRM_Utils_Array::value('action', $requestParams));
     if (!is_array($params)) {
         CRM_Utils_JSON::output(array('is_error' => 1, 'error_message' => 'invalid json format: ?{"param_with_double_quote":"value"}'));
     }
     $params['check_permissions'] = TRUE;
     $params['version'] = 3;
     $_GET['json'] = $requestParams['json'] = 1;
     // $requestParams is local-only; this line seems pointless unless there's a side-effect influencing other functions
     if (!$params['sequential']) {
         $params['sequential'] = 1;
     }
     // trap all fatal errors
     $errorScope = CRM_Core_TemporaryErrorScope::create(array('CRM_Utils_REST', 'fatal'));
     $result = civicrm_api($entity, $action, $params);
     unset($errorScope);
     echo self::output($result);
     CRM_Utils_System::civiExit();
 }
开发者ID:kidaa30,项目名称:yes,代码行数:42,代码来源:REST.php

示例5: unset

 /**
  * Singleton function used to manage this object.
  *
  * @param bool $loadFromDB
  *   whether to load from the database.
  * @param bool $force
  *   whether to force a reconstruction.
  *
  * @return CRM_Core_Config
  */
 public static function &singleton($loadFromDB = TRUE, $force = FALSE)
 {
     if (self::$_singleton === NULL || $force) {
         // goto a simple error handler
         $GLOBALS['civicrm_default_error_scope'] = CRM_Core_TemporaryErrorScope::create(array('CRM_Core_Error', 'handle'));
         $errorScope = CRM_Core_TemporaryErrorScope::create(array('CRM_Core_Error', 'simpleHandler'));
         // lets ensure we set E_DEPRECATED to minimize errors
         // CRM-6327
         if (defined('E_DEPRECATED')) {
             error_reporting(error_reporting() & ~E_DEPRECATED);
         }
         // first, attempt to get configuration object from cache
         $cache = CRM_Utils_Cache::singleton();
         self::$_singleton = $cache->get('CRM_Core_Config' . CRM_Core_Config::domainID());
         // if not in cache, fire off config construction
         if (!self::$_singleton) {
             self::$_singleton = new CRM_Core_Config();
             self::$_singleton->_initialize($loadFromDB);
             //initialize variables. for gencode we cannot load from the
             //db since the db might not be initialized
             if ($loadFromDB) {
                 // initialize stuff from the settings file
                 self::$_singleton->setCoreVariables();
                 self::$_singleton->_initVariables();
                 // I don't think we need to do this twice
                 // however just keeping this commented for now in 4.4
                 // in case we hit any issues - CRM-13064
                 // We can safely delete this once we release 4.4.4
                 // self::$_singleton->setCoreVariables();
             }
             $cache->set('CRM_Core_Config' . CRM_Core_Config::domainID(), self::$_singleton);
         } else {
             // we retrieve the object from memcache, so we now initialize the objects
             self::$_singleton->_initialize($loadFromDB);
             // CRM-9803, NYSS-4822
             // this causes various settings to be reset and hence we should
             // only use the config object that we retrieved from memcache
         }
         self::$_singleton->initialized = 1;
         if (isset(self::$_singleton->customPHPPathDir) && self::$_singleton->customPHPPathDir) {
             $include_path = self::$_singleton->customPHPPathDir . PATH_SEPARATOR . get_include_path();
             set_include_path($include_path);
         }
         // set the callback at the very very end, to avoid an infinite loop
         // set the error callback
         unset($errorScope);
         // call the hook so other modules can add to the config
         // again doing this at the very very end
         CRM_Utils_Hook::config(self::$_singleton);
         // make sure session is always initialised
         $session = CRM_Core_Session::singleton();
         // for logging purposes, pass the userID to the db
         $userID = $session->get('userID');
         if ($userID) {
             CRM_Core_DAO::executeQuery('SET @civicrm_user_id = %1', array(1 => array($userID, 'Integer')));
         }
         // initialize authentication source
         self::$_singleton->initAuthSrc();
     }
     return self::$_singleton;
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:71,代码来源:Config.php


注:本文中的CRM_Core_TemporaryErrorScope::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。