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


PHP CRM_Core_Config::_singleton方法代碼示例

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


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

示例1: free

 /**
  * Resets the singleton, so that the next call to CRM_Core_Config::singleton()
  * reloads completely.
  *
  * While normally we could call the singleton function with $force = TRUE,
  * this function addresses a very specific use-case in the CiviCRM installer,
  * where we cannot yet force a reload, but we want to make sure that the next
  * call to this object gets a fresh start (ex: to initialize the DAO).
  */
 public function free()
 {
     self::$_singleton = NULL;
 }
開發者ID:kcristiano,項目名稱:civicrm-core,代碼行數:13,代碼來源:Config.php

示例2: array

 /**
  * Singleton function used to manage this object.
  *
  * @param $loadFromDB boolean  whether to load from the database
  * @param $force      boolean  whether to force a reconstruction
  *
  * @return object
  * @static
  */
 static function &singleton($loadFromDB = TRUE, $force = FALSE)
 {
     if (self::$_singleton === NULL || $force) {
         // goto a simple error handler
         $GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_CALLBACK;
         $GLOBALS['_PEAR_default_error_options'] = 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 dont 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 retrived 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
         CRM_Core_Error::setCallback();
         // 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:hguru,項目名稱:224Civi,代碼行數:70,代碼來源:Config.php

示例3:

 /**
  * Singleton function used to manage this object.
  *
  * @param $loadFromDB boolean  whether to load from the database
  * @param $force      boolean  whether to force a reconstruction
  *
  * @return object
  * @static
  */
 static function &singleton($loadFromDB = true, $force = false)
 {
     if (self::$_singleton === null || $force) {
         // first, attempt to get configuration object from cache
         require_once 'CRM/Utils/Cache.php';
         $cache =& CRM_Utils_Cache::singleton();
         self::$_singleton = $cache->get('CRM_Core_Config');
         // if not in cache, fire off config construction
         if (!self::$_singleton) {
             self::$_singleton = new CRM_Core_Config();
             self::$_singleton->_initialize();
             //initialize variables. for gencode we cannot load from the
             //db since the db might not be initialized
             if ($loadFromDB) {
                 self::$_singleton->_initVariables();
                 // retrieve and overwrite stuff from the settings file
                 self::$_singleton->setCoreVariables();
             }
             $cache->set('CRM_Core_Config', self::$_singleton);
         } else {
             // we retrieve the object from memcache, so we now initialize the objects
             self::$_singleton->_initialize();
         }
         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
         CRM_Core_Error::setCallback();
     }
     return self::$_singleton;
 }
開發者ID:ksecor,項目名稱:civicrm,代碼行數:43,代碼來源:Config.php

示例4:

 /**
  * Singleton function used to manage this object.
  *
  * @param $loadFromDB boolean  whether to load from the database
  * @param $force      boolean  whether to force a reconstruction
  *
  * @return object
  * @static
  */
 static function &singleton($loadFromDB = true, $force = false)
 {
     if (self::$_singleton === null || $force) {
         // 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
         require_once 'CRM/Utils/Cache.php';
         $cache =& CRM_Utils_Cache::singleton();
         self::$_singleton = $cache->get('CRM_Core_Config');
         // 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) {
                 self::$_singleton->_initVariables();
                 // retrieve and overwrite stuff from the settings file
                 self::$_singleton->setCoreVariables();
             }
             $cache->set('CRM_Core_Config', self::$_singleton);
         } else {
             // we retrieve the object from memcache, so we now initialize the objects
             self::$_singleton->_initialize($loadFromDB);
             // add component specific settings
             self::$_singleton->componentRegistry->addConfig(self::$_singleton);
         }
         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
         CRM_Core_Error::setCallback();
         // call the hook so other modules can add to the config
         // again doing this at the very very end
         require_once 'CRM/Utils/Hook.php';
         CRM_Utils_Hook::config(self::$_singleton);
         // make sure session is always initialised
         $session = CRM_Core_Session::singleton();
     }
     return self::$_singleton;
 }
開發者ID:hampelm,項目名稱:Ginsberg-CiviDemo,代碼行數:56,代碼來源:Config.php


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