本文整理汇总了PHP中CRM_Utils_Cache类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Cache类的具体用法?PHP CRM_Utils_Cache怎么用?PHP CRM_Utils_Cache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Utils_Cache类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: tearDown
public function tearDown()
{
global $civicrm_setting;
$civicrm_setting = $this->origSetting;
CRM_Utils_Cache::singleton()->flush();
parent::tearDown();
}
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:7,代码来源:SettingTest.php
示例2: create
/**
* Create civicrm settings. This is the same as add but it clears the cache and
* reloads the config object
*
* @param array $params
* Associated array of civicrm variables.
*
* @return void
*/
public static function create($params)
{
self::add($params);
$cache = CRM_Utils_Cache::singleton();
$cache->delete('CRM_Core_Config');
$cache->delete('CRM_Core_Config' . CRM_Core_Config::domainID());
$config = CRM_Core_Config::singleton(TRUE, TRUE);
}
开发者ID:riyadennis,项目名称:my_civicrm,代码行数:17,代码来源:ConfigSetting.php
示例3: singleton
/**
* @param bool $fresh
* @return CRM_Cxn_CiviCxnHttp
*/
public static function singleton($fresh = FALSE)
{
if (self::$singleton === NULL || $fresh) {
$cache = CRM_Utils_Cache::create(array('name' => 'CiviCxnHttp', 'type' => Civi::settings()->get('debug_enabled') ? 'ArrayCache' : array('SqlGroup', 'ArrayCache'), 'prefetch' => FALSE));
self::$singleton = new CRM_Cxn_CiviCxnHttp($cache);
}
return self::$singleton;
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:12,代码来源:CiviCxnHttp.php
示例4: setCache
static function setCache($values, $group, $componentID = NULL, $contactID = NULL)
{
if (!isset(self::$_cache)) {
self::$_cache = array();
}
$cacheKey = "CRM_Setting_{$group}_{$componentID}_{$contactID}";
self::$_cache[$cacheKey] = $values;
$globalCache = CRM_Utils_Cache::singleton();
$result = $globalCache->set($cacheKey, $values);
return $cacheKey;
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:11,代码来源:Setting.php
示例5: CRM_Utils_Cache_Memcache
/**
* singleton function used to manage this object
*
* @param string $host the memcached server host
* @param int $port the memcached server port
* @param int $timeout the default timeout
*
* @return object
* @static
*
*/
static function &singleton($host = 'localhost', $port = 11211, $timeout = 3600)
{
if (self::$_singleton === null) {
if (defined('CIVICRM_USE_MEMCACHE') && CIVICRM_USE_MEMCACHE) {
require_once 'CRM/Utils/Cache/Memcache.php';
self::$_singleton = new CRM_Utils_Cache_Memcache($host, $port, $timeout);
} else {
self::$_singleton = new CRM_Utils_Cache();
}
}
return self::$_singleton;
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:23,代码来源:Cache.php
示例6: testSetGetItem
public function testSetGetItem()
{
$originalValue = array('abc' => 'def');
CRM_Core_BAO_Cache::setItem($originalValue, __CLASS__, 'testSetGetItem');
$return_1 = CRM_Core_BAO_Cache::getItem(__CLASS__, 'testSetGetItem');
$this->assertEquals($originalValue, $return_1);
// Wipe out any in-memory copies of the cache. Check to see if the SQL
// read is correct.
CRM_Core_BAO_Cache::$_cache = NULL;
CRM_Utils_Cache::$_singleton = NULL;
$return_2 = CRM_Core_BAO_Cache::getItem(__CLASS__, 'testSetGetItem');
$this->assertEquals($originalValue, $return_2);
}
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:13,代码来源:CacheTest.php
示例7: getPetitionActivityType
/**
* Find the activity type ID for petitions.
*
* @return int
* The activity type ID.
*/
public static function getPetitionActivityType()
{
$cache = CRM_Utils_Cache::singleton();
$petitionActivityType = $cache->get('petitionemail_petitionActivityType');
if (empty($petitionActivityType)) {
try {
$petitionTypeParams = array('name' => "activity_type", 'api.OptionValue.getsingle' => array('option_group_id' => '$value.id', 'name' => "Petition", 'options' => array('limit' => 1)), 'options' => array('limit' => 1));
$petitionTypeInfo = civicrm_api3('OptionGroup', 'getsingle', $petitionTypeParams);
} catch (CiviCRM_API3_Exception $e) {
$error = $e->getMessage();
CRM_Core_Error::debug_log_message(t('API Error: %1', array(1 => $error, 'domain' => 'com.aghstrategies.petitionemail')));
}
if (empty($petitionTypeInfo['api.OptionValue.getsingle']['value'])) {
return;
} else {
$petitionActivityType = $petitionTypeInfo['api.OptionValue.getsingle']['value'];
$cache->set('petitionemail_petitionActivityType', $petitionActivityType);
}
}
return $petitionActivityType;
}
开发者ID:aghstrategies,项目名称:com.aghstrategies.petitionemail,代码行数:27,代码来源:Utils.php
示例8: elseif
/**
* Singleton function used to manage this object.
*
* @return CRM_Utils_Cache_Interface
*/
public static function &singleton()
{
if (self::$_singleton === NULL) {
$className = 'ArrayCache';
// default to ArrayCache for now
// Maintain backward compatibility for now.
// Setting CIVICRM_USE_MEMCACHE or CIVICRM_USE_ARRAYCACHE will
// override the CIVICRM_DB_CACHE_CLASS setting.
// Going forward, CIVICRM_USE_xxxCACHE should be deprecated.
if (defined('CIVICRM_USE_MEMCACHE') && CIVICRM_USE_MEMCACHE) {
$className = 'Memcache';
} elseif (defined('CIVICRM_USE_ARRAYCACHE') && CIVICRM_USE_ARRAYCACHE) {
$className = 'ArrayCache';
} elseif (defined('CIVICRM_DB_CACHE_CLASS') && CIVICRM_DB_CACHE_CLASS) {
$className = CIVICRM_DB_CACHE_CLASS;
}
// a generic method for utilizing any of the available db caches.
$dbCacheClass = 'CRM_Utils_Cache_' . $className;
$settings = self::getCacheSettings($className);
self::$_singleton = new $dbCacheClass($settings);
}
return self::$_singleton;
}
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:28,代码来源:Cache.php
示例9: populate
/**
* DEPRECATED generic populate method
* All pseudoconstant functions that use this method are also deprecated.
*
* The static array $var is populated from the db
* using the <b>$name DAO</b>.
*
* Note: any database errors will be trapped by the DAO.
*
* @param array $var the associative array we will fill
* @param string $name the name of the DAO
* @param boolean $all get all objects. default is to get only active ones.
* @param string $retrieve the field that we are interested in (normally name, differs in some objects)
* @param string $filter the field that we want to filter the result set with
* @param string $condition the condition that gets passed to the final query as the WHERE clause
*
* @return void
* @access public
* @static
*/
public static function populate(&$var, $name, $all = FALSE, $retrieve = 'name', $filter = 'is_active', $condition = NULL, $orderby = NULL, $key = 'id', $force = NULL)
{
$cacheKey = "CRM_PC_{$name}_{$all}_{$key}_{$retrieve}_{$filter}_{$condition}_{$orderby}";
$cache = CRM_Utils_Cache::singleton();
$var = $cache->get($cacheKey);
if ($var && empty($force)) {
return $var;
}
$object = new $name();
$object->selectAdd();
$object->selectAdd("{$key}, {$retrieve}");
if ($condition) {
$object->whereAdd($condition);
}
if (!$orderby) {
$object->orderBy($retrieve);
} else {
$object->orderBy($orderby);
}
if (!$all) {
$object->{$filter} = 1;
}
$object->find();
$var = array();
while ($object->fetch()) {
$var[$object->{$key}] = $object->{$retrieve};
}
$cache->set($cacheKey, $var);
}
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:49,代码来源:PseudoConstant.php
示例10: getTableColumnGroup
/**
* Get the database table name and column name for a custom field.
*
* @param int $fieldID
* The fieldID of the custom field.
* @param bool $force
* Force the sql to be run again (primarily used for tests).
*
* @return array
* fatal is fieldID does not exists, else array of tableName, columnName
*/
public static function getTableColumnGroup($fieldID, $force = FALSE)
{
$cacheKey = "CRM_Core_DAO_CustomField_CustomGroup_TableColumn_{$fieldID}";
$cache = CRM_Utils_Cache::singleton();
$fieldValues = $cache->get($cacheKey);
if (empty($fieldValues) || $force) {
$query = "\nSELECT cg.table_name, cf.column_name, cg.id\nFROM civicrm_custom_group cg,\n civicrm_custom_field cf\nWHERE cf.custom_group_id = cg.id\nAND cf.id = %1";
$params = array(1 => array($fieldID, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
if (!$dao->fetch()) {
CRM_Core_Error::fatal();
}
$dao->free();
$fieldValues = array($dao->table_name, $dao->column_name, $dao->id);
$cache->set($cacheKey, $fieldValues);
}
return $fieldValues;
}
开发者ID:Hack4Eugene,项目名称:Hack4Cause2016,代码行数:29,代码来源:CustomField.php
示例11: getDefaultFromAddress
/**
* Find the site's default "from" address.
*
* @return string
* The default "from" name and address.
*/
public function getDefaultFromAddress()
{
if (empty($this->defaultFromAddress)) {
$cache = CRM_Utils_Cache::singleton();
$this->defaultFromAddress = $cache->get('petitionemail_defaultFromAddress');
}
if (empty($this->defaultFromAddress)) {
try {
$defaultMailParams = array('name' => "from_email_address", 'options' => array('limit' => 1), 'api.OptionValue.getsingle' => array('is_default' => 1, 'options' => array('limit' => 1)));
$defaultMail = civicrm_api3('OptionGroup', 'getsingle', $defaultMailParams);
if (empty($defaultMail['api.OptionValue.getsingle']['label']) || $defaultMail['api.OptionValue.getsingle']['label'] == $defaultMail['api.OptionValue.getsingle']['name']) {
// No site email.
// TODO: leave some kind of message with explanation.
return NULL;
}
$this->defaultFromAddress = $defaultMail['api.OptionValue.getsingle']['label'];
$cache->set('petitionemail_defaultFromAddress', $this->defaultFromAddress);
} catch (CiviCRM_API3_Exception $e) {
$error = $e->getMessage();
CRM_Core_Error::debug_log_message(t('API Error: %1', array(1 => $error, 'domain' => 'com.aghstrategies.petitionemail')));
}
}
return $this->defaultFromAddress;
}
开发者ID:aghstrategies,项目名称:com.aghstrategies.petitionemail,代码行数:30,代码来源:Interface.php
示例12: populate
/**
* populate the object from the database. generic populate
* method
*
* The static array $var is populated from the db
* using the <b>$name DAO</b>.
*
* Note: any database errors will be trapped by the DAO.
*
* @param array $var the associative array we will fill
* @param string $name the name of the DAO
* @param boolean $all get all objects. default is to get only active ones.
* @param string $retrieve the field that we are interested in (normally name, differs in some objects)
* @param string $filter the field that we want to filter the result set with
* @param string $condition the condition that gets passed to the final query as the WHERE clause
*
* @return void
* @access public
* @static
*/
public static function populate(&$var, $name, $all = false, $retrieve = 'name', $filter = 'is_active', $condition = null, $orderby = null, $key = 'id')
{
$cacheKey = "CRM_PC_{$name}_{$all}_{$key}_{$retrieve}_{$filter}_{$condition}_{$orderby}";
$cache =& CRM_Utils_Cache::singleton();
$var = $cache->get($cacheKey);
if ($var) {
return $var;
}
require_once str_replace('_', DIRECTORY_SEPARATOR, $name) . ".php";
eval('$object = new ' . $name . '( );');
$object->selectAdd();
$object->selectAdd("{$key}, {$retrieve}");
if ($condition) {
$object->whereAdd($condition);
}
if (!$orderby) {
$object->orderBy($retrieve);
} else {
$object->orderBy($orderby);
}
if (!$all) {
$object->{$filter} = 1;
}
$object->find();
$var = array();
while ($object->fetch()) {
$var[$object->{$key}] = $object->{$retrieve};
}
$cache->set($cacheKey, $var);
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:50,代码来源:PseudoConstant.php
示例13: group
/**
* @param $type
* @param null $contactID
* @param string $tableName
* @param null $allGroups
* @param null $includedGroups
*
* @return array
*/
public static function group($type, $contactID = NULL, $tableName = 'civicrm_saved_search', $allGroups = NULL, $includedGroups = NULL)
{
$acls = CRM_ACL_BAO_Cache::build($contactID);
$ids = array();
if (!empty($acls)) {
$aclKeys = array_keys($acls);
$aclKeys = implode(',', $aclKeys);
$cacheKey = "{$tableName}-{$aclKeys}";
$cache = CRM_Utils_Cache::singleton();
$ids = $cache->get($cacheKey);
if (!$ids) {
$query = "\nSELECT a.operation, a.object_id\n FROM civicrm_acl_cache c, civicrm_acl a\n WHERE c.acl_id = a.id\n AND a.is_active = 1\n AND a.object_table = %1\n AND a.id IN ( {$aclKeys} )\nGROUP BY a.operation,a.object_id\nORDER BY a.object_id\n";
$params = array(1 => array($tableName, 'String'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
while ($dao->fetch()) {
if ($dao->object_id) {
if (self::matchType($type, $dao->operation)) {
$ids[] = $dao->object_id;
}
} else {
// this user has got the permission for all objects of this type
// check if the type matches
if (self::matchType($type, $dao->operation)) {
foreach ($allGroups as $id => $dontCare) {
$ids[] = $id;
}
}
break;
}
}
$cache->set($cacheKey, $ids);
}
}
if (empty($ids) && !empty($includedGroups) && is_array($includedGroups)) {
$ids = $includedGroups;
}
CRM_Utils_Hook::aclGroup($type, $contactID, $tableName, $allGroups, $ids);
return $ids;
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:48,代码来源:ACL.php
示例14: getOptionValuesArray
/**
* Get the values of all option values given an option group ID. Store in system cache
* Does not take any filtering arguments. The object is to avoid hitting the DB and retrieve
* from memory
*
* @param int $optionGroupID
* The option group for which we want the values from.
*
* @return array
* an array of array of values for this option group
*/
public static function getOptionValuesArray($optionGroupID)
{
// check if we can get the field values from the system cache
$cacheKey = "CRM_Core_BAO_OptionValue_OptionGroupID_{$optionGroupID}";
$cache = CRM_Utils_Cache::singleton();
$optionValues = $cache->get($cacheKey);
if (empty($optionValues)) {
$dao = new CRM_Core_DAO_OptionValue();
$dao->option_group_id = $optionGroupID;
$dao->orderBy('weight ASC, label ASC');
$dao->find();
$optionValues = array();
while ($dao->fetch()) {
$optionValues[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $optionValues[$dao->id]);
}
$cache->set($cacheKey, $optionValues);
}
return $optionValues;
}
开发者ID:kidaa30,项目名称:yes,代码行数:31,代码来源:OptionValue.php
示例15: commonProcess
public function commonProcess(&$params)
{
require_once "CRM/Core/BAO/Setting.php";
CRM_Core_BAO_Setting::add($params);
// also delete the CRM_Core_Config key from the database
$cache =& CRM_Utils_Cache::singleton();
$cache->delete('CRM_Core_Config');
// save autocomplete search options
if (CRM_Utils_Array::value('autocompleteContactSearch', $params)) {
$config =& new CRM_Core_DAO_Preferences();
$config->domain_id = CRM_Core_Config::domainID();
$config->find(true);
$config->contact_autocomplete_options = CRM_Core_BAO_CustomOption::VALUE_SEPERATOR . implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, array_keys($params['autocompleteContactSearch'])) . CRM_Core_BAO_CustomOption::VALUE_SEPERATOR;
$config->save();
}
CRM_Core_Session::setStatus(ts('Your changes have been saved.'));
}
开发者ID:ksecor,项目名称:civicrm,代码行数:17,代码来源:Setting.php
示例16: membershipTypeCreate
/**
* @param array $params
*
* @return mixed
*/
public function membershipTypeCreate($params = array())
{
CRM_Member_PseudoConstant::flush('membershipType');
CRM_Core_Config::clearDBCache();
$this->setupIDs['contact'] = $memberOfOrganization = $this->organizationCreate();
$params = array_merge(array('name' => 'General', 'duration_unit' => 'year', 'duration_interval' => 1, 'period_type' => 'rolling', 'member_of_contact_id' => $memberOfOrganization, 'domain_id' => 1, 'financial_type_id' => 2, 'is_active' => 1, 'sequential' => 1, 'visibility' => 'Public'), $params);
$result = $this->callAPISuccess('MembershipType', 'Create', $params);
CRM_Member_PseudoConstant::flush('membershipType');
CRM_Utils_Cache::singleton()->flush();
return $result['id'];
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:16,代码来源:CiviUnitTestCase.php
示例17: flushCache
/**
* Reset the memory cache, typically memcached
*/
static function flushCache($daoName = null)
{
// flush out all cache entries so we can reload new data
// a bit aggressive, but livable for now
require_once 'CRM/Utils/Cache.php';
$cache =& CRM_Utils_Cache::singleton();
$cache->flush();
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:11,代码来源:System.php
示例18: getCache
/**
* @return CRM_Utils_Cache_Interface
*/
public function getCache()
{
if ($this->cache === NULL) {
$cacheGroup = md5(serialize(array('ext', $this->parameters)));
// Extension system starts before container. Manage our own cache.
$this->cache = CRM_Utils_Cache::create(array('name' => $cacheGroup, 'type' => array('*memory*', 'SqlGroup', 'ArrayCache'), 'prefetch' => TRUE));
}
return $this->cache;
}
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:12,代码来源:System.php
示例19: getAllPaymentProcessors
/**
* Get all payment processors as an array of objects.
*
* @param string|NULL $mode
* only return this mode - test|live or NULL for all
* @param bool $reset
*
* @throws CiviCRM_API3_Exception
* @return array
*/
public static function getAllPaymentProcessors($mode, $reset = FALSE)
{
$cacheKey = 'CRM_Financial_BAO_Payment_Processor_' . ($mode ? 'test' : 'all') . '_' . CRM_Core_Config::domainID();
if (!$reset) {
$processors = CRM_Utils_Cache::singleton()->get($cacheKey);
if (!empty($processors)) {
return $processors;
}
}
$retrievalParameters = array('is_active' => TRUE, 'domain_id' => CRM_Core_Config::domainID(), 'options' => array('sort' => 'is_default DESC, name'), 'api.payment_processor_type.getsingle' => 1);
if ($mode == 'test') {
$retrievalParameters['is_test'] = 1;
} elseif ($mode == 'live') {
$retrievalParameters['is_test'] = 0;
}
$processors = civicrm_api3('payment_processor', 'get', $retrievalParameters);
foreach ($processors['values'] as $processor) {
$fieldsToProvide = array('user_name', 'password', 'signature', 'subject', 'is_recur');
foreach ($fieldsToProvide as $field) {
// Prevent e-notices in processor classes when not configured.
if (!isset($processor[$field])) {
$processors['values'][$processor['id']][$field] = NULL;
}
}
$processors['values'][$processor['id']]['payment_processor_type'] = $processor['payment_processor_type'] = $processors['values'][$processor['id']]['api.payment_processor_type.getsingle']['name'];
$processors['values'][$processor['id']]['object'] = Civi\Payment\System::singleton()->getByProcessor($processor);
}
CRM_Utils_Cache::singleton()->set($cacheKey, $processors['values']);
return $processors['values'];
}
开发者ID:nganivet,项目名称:civicrm-core,代码行数:40,代码来源:PaymentProcessor.php
示例20: getSelectElements
/**
* Get a list of elements for select box.
* Note that this used to default to using the hex(01) character - which results in an invalid character being used in form fields
* which was not handled well be anything that loaded & resaved the html (outside core)
* The use of this separator is now explicit in the calling functions as a step towards it's removal
*
* @param bool $all
* @param bool $isSeparator
* @param string $separator
*
* @return mixed
*/
public static function getSelectElements($all = FALSE, $isSeparator = TRUE, $separator = '__')
{
static $_cache = NULL;
if ($_cache === NULL) {
$_cache = array();
}
$argString = $all ? 'CRM_CT_GSE_1' : 'CRM_CT_GSE_0';
$argString .= $isSeparator ? '_1' : '_0';
$argString .= $separator;
if (!array_key_exists($argString, $_cache)) {
$cache = CRM_Utils_Cache::singleton();
$_cache[$argString] = $cache->get($argString);
if (!$_cache[$argString]) {
$_cache[$argString] = array();
$sql = "\nSELECT c.name as child_name , c.label as child_label , c.id as child_id,\n p.name as parent_name, p.label as parent_label, p.id as parent_id\nFROM civicrm_contact_type c\nLEFT JOIN civicrm_contact_type p ON ( c.parent_id = p.id )\nWHERE ( c.name IS NOT NULL )\n";
if ($all === FALSE) {
$sql .= "\nAND c.is_active = 1\nAND ( p.is_active = 1 OR p.id IS NULL )\n";
}
$sql .= " ORDER BY c.id";
$values = array();
$dao = CRM_Core_DAO::executeQuery($sql);
while ($dao->fetch()) {
if (!empty($dao->parent_id)) {
$key = $isSeparator ? $dao->parent_name . $separator . $dao->child_name : $dao->child_name;
$label = "- {$dao->child_label}";
$pName = $dao->parent_name;
} else {
$key = $dao->child_name;
$label = $dao->child_label;
$pName = $dao->child_name;
}
if (!isset($values[$pName])) {
$values[$pName] = array();
}
$values[$pName][] = array('key' => $key, 'label' => $label);
}
$selectElements = array();
foreach ($values as $pName => $elements) {
foreach ($elements as $element) {
$selectElements[$element['key']] = $element['label'];
}
}
$_cache[$argString] = $selectElements;
$cache->set($argString, $_cache[$argString]);
}
}
return $_cache[$argString];
}
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:60,代码来源:ContactType.php
注:本文中的CRM_Utils_Cache类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论