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


PHP Civi::cache方法代码示例

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


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

示例1: getMetadata

 /**
  * WARNING: This interface may change.
  *
  * This provides information about the setting - similar to the fields concept for DAO information.
  * As the setting is serialized code creating validation setting input needs to know the data type
  * This also helps move information out of the form layer into the data layer where people can interact with
  * it via the API or other mechanisms. In order to keep this consistent it is important the form layer
  * also leverages it.
  *
  * Note that this function should never be called when using the runtime getvalue function. Caching works
  * around the expectation it will be called during setting administration
  *
  * Function is intended for configuration rather than runtime access to settings
  *
  * The following params will filter the result. If none are passed all settings will be returns
  *
  * @param array $filters
  * @param int $domainID
  *
  * @return array
  *   the following information as appropriate for each setting
  *   - name
  *   - type
  *   - default
  *   - add (CiviCRM version added)
  *   - is_domain
  *   - is_contact
  *   - description
  *   - help_text
  */
 public static function getMetadata($filters = array(), $domainID = NULL)
 {
     if ($domainID === NULL) {
         $domainID = \CRM_Core_Config::domainID();
     }
     $cache = \Civi::cache('settings');
     $cacheString = 'settingsMetadata_' . $domainID . '_';
     // the caching into 'All' seems to be a duplicate of caching to
     // settingsMetadata__ - I think the reason was to cache all settings as defined & then those altered by a hook
     $settingsMetadata = $cache->get($cacheString);
     $cached = is_array($settingsMetadata);
     if (!$cached) {
         $settingsMetadata = $cache->get(self::ALL);
         if (empty($settingsMetadata)) {
             global $civicrm_root;
             $metaDataFolders = array($civicrm_root . '/settings');
             \CRM_Utils_Hook::alterSettingsFolders($metaDataFolders);
             $settingsMetadata = self::loadSettingsMetaDataFolders($metaDataFolders);
             $cache->set(self::ALL, $settingsMetadata);
         }
     }
     \CRM_Utils_Hook::alterSettingsMetaData($settingsMetadata, $domainID, NULL);
     if (!$cached) {
         $cache->set($cacheString, $settingsMetadata);
     }
     self::_filterSettingsSpecification($filters, $settingsMetadata);
     return $settingsMetadata;
 }
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:58,代码来源:SettingsMetadata.php

示例2: flush

 /**
  * Flush all in-memory and persistent caches related to settings.
  *
  * @return $this
  */
 public function flush()
 {
     $this->mandatory = NULL;
     $this->cache->flush();
     \Civi::cache('settings')->flush();
     // SettingsMetadata; not guaranteed to use same cache.
     foreach ($this->bagsByDomain as $bag) {
         /** @var SettingsBag $bag */
         $bag->loadValues();
         $bag->loadDefaults($this->getDefaults('domain'));
         $bag->loadMandatory($this->getMandatory('domain'));
     }
     foreach ($this->bagsByContact as $bag) {
         /** @var SettingsBag $bag */
         $bag->loadValues();
         $bag->loadDefaults($this->getDefaults('contact'));
         $bag->loadMandatory($this->getMandatory('contact'));
     }
     return $this;
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:25,代码来源:SettingsManager.php

示例3: create

 /**
  * Create default instance.
  *
  * @return CRM_Core_CommunityMessages
  */
 public static function create()
 {
     return new CRM_Core_CommunityMessages(Civi::cache('community_messages'), CRM_Utils_HttpClient::singleton());
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:9,代码来源:CommunityMessages.php

示例4: singleton

 /**
  * Get or set the single instance of CRM_Core_Resources.
  *
  * @param CRM_Core_Resources $instance
  *   New copy of the manager.
  * @return CRM_Core_Resources
  */
 public static function singleton(CRM_Core_Resources $instance = NULL)
 {
     if ($instance !== NULL) {
         self::$_singleton = $instance;
     }
     if (self::$_singleton === NULL) {
         $sys = CRM_Extension_System::singleton();
         $cache = Civi::cache('js_strings');
         self::$_singleton = new CRM_Core_Resources($sys->getMapper(), $cache, CRM_Core_Config::isUpgradeMode() ? NULL : 'resCacheCode');
     }
     return self::$_singleton;
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:19,代码来源:Resources.php

示例5: testGetExtensionSetting

 /**
  * Check that setting defined in extension can be retrieved.
  */
 public function testGetExtensionSetting()
 {
     $this->hookClass->setHook('civicrm_alterSettingsFolders', array($this, 'setExtensionMetadata'));
     $data = NULL;
     // the caching of data to all duplicates the caching of data to the empty string
     CRM_Core_BAO_Cache::setItem($data, 'CiviCRM setting Spec', 'All');
     CRM_Core_BAO_Cache::setItem($data, 'CiviCRM setting Specs', 'settingsMetadata__');
     Civi::cache('settings')->flush();
     $fields = $this->callAPISuccess('setting', 'getfields', array('filters' => array('group_name' => 'Test Settings')));
     $this->assertArrayHasKey('test_key', $fields['values']);
     $this->callAPISuccess('setting', 'create', array('test_key' => 'keyset'));
     $this->assertEquals('keyset', Civi::settings()->get('test_key'));
     $result = $this->callAPISuccess('setting', 'getvalue', array('name' => 'test_key', 'group' => 'Test Settings'));
     $this->assertEquals('keyset', $result);
 }
开发者ID:sdekok,项目名称:civicrm-core,代码行数:18,代码来源:SettingTest.php

示例6: checkAll

 /**
  * Run some sanity checks.
  *
  * This could become a hook so that CiviCRM can run both built-in
  * configuration & sanity checks, and modules/extensions can add
  * their own checks.
  *
  * We might even expose the results of these checks on the Wordpress
  * plugin status page or the Drupal admin/reports/status path.
  *
  * @param bool $max
  *   Whether to return just the maximum non-hushed severity
  *
  * @return array
  *   Array of messages
  * @link https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_requirements
  */
 public static function checkAll($max = FALSE)
 {
     $checks = array();
     $checks[] = new CRM_Utils_Check_Security();
     $checks[] = new CRM_Utils_Check_Env();
     $compInfo = CRM_Core_Component::getEnabledComponents();
     foreach ($compInfo as $compObj) {
         switch ($compObj->info['name']) {
             case 'CiviCase':
                 $checks[] = new CRM_Utils_Check_Case(CRM_Case_XMLRepository::singleton(), CRM_Case_PseudoConstant::caseType('name'));
                 break;
             default:
         }
     }
     $messages = array();
     foreach ($checks as $check) {
         $messages = array_merge($messages, $check->checkAll());
     }
     CRM_Utils_Hook::check($messages);
     foreach ($messages as $key => $message) {
         $hush = self::checkHushSnooze($message);
         $message->setVisible(!$hush);
     }
     uasort($messages, array(__CLASS__, 'severitySort'));
     $maxSeverity = 1;
     foreach ($messages as $message) {
         if (!$message->isVisible()) {
             continue;
         }
         $maxSeverity = max(1, $message->getLevel());
         break;
     }
     Civi::cache()->set('systemCheckSeverity', $maxSeverity);
     $timestamp = time();
     Civi::cache()->set('systemCheckDate', $timestamp);
     return $max ? $maxSeverity : $messages;
 }
开发者ID:nyimbi,项目名称:civicrm-core,代码行数:54,代码来源:Check.php

示例7: statusCheck

 /**
  * Show status in the footer
  *
  * @param CRM_Core_Smarty $template
  */
 public static function statusCheck($template)
 {
     if (CRM_Core_Config::isUpgradeMode()) {
         return;
     }
     //  check date of last cache and compare to today's date
     $systemCheckDate = Civi::cache()->get('systemCheckDate');
     if ($systemCheckDate > strtotime("one day ago")) {
         $statusSeverity = Civi::cache()->get('systemCheckSeverity');
     }
     //  calls helper function in CRM_Utils_Check
     if (empty($statusSeverity)) {
         $statusSeverity = CRM_Utils_Check::checkAll(TRUE);
     }
     switch ($statusSeverity) {
         case 7:
             $statusMessage = ts('System Status: Emergency');
             break;
         case 6:
             $statusMessage = ts('System Status: Alert');
             break;
         case 5:
             $statusMessage = ts('System Status: Critical');
             break;
         case 4:
             $statusMessage = ts('System Status: Error');
             break;
         case 3:
             $statusMessage = ts('System Status: Warning');
             break;
         case 2:
             $statusMessage = ts('System Status: Notice');
             break;
         default:
             $statusMessage = ts('System Status: Ok');
     }
     // TODO: get status from CRM_Utils_Check, if cached
     $template->assign('footer_status_severity', $statusSeverity);
     $template->assign('footer_status_message', $statusMessage);
 }
开发者ID:nyimbi,项目名称:civicrm-core,代码行数:45,代码来源:Invoke.php


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