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


PHP cache_helper::early_get_cache_plugins方法代碼示例

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


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

示例1: load

 /**
  * Loads the configuration file and parses its contents into the expected structure.
  *
  * @param array|false $configuration Can be used to force a configuration. Should only be used when truly required.
  * @return boolean
  */
 public function load($configuration = false)
 {
     global $CFG;
     if ($configuration === false) {
         $configuration = $this->include_configuration();
     }
     $this->configstores = array();
     $this->configdefinitions = array();
     $this->configlocks = array();
     $this->configmodemappings = array();
     $this->configdefinitionmappings = array();
     $this->configlockmappings = array();
     $siteidentifier = 'unknown';
     if (array_key_exists('siteidentifier', $configuration)) {
         $siteidentifier = $configuration['siteidentifier'];
     }
     $this->siteidentifier = $siteidentifier;
     // Filter the lock instances.
     $defaultlock = null;
     foreach ($configuration['locks'] as $conf) {
         if (!is_array($conf)) {
             // Something is very wrong here.
             continue;
         }
         if (!array_key_exists('name', $conf)) {
             // Not a valid definition configuration.
             continue;
         }
         $name = $conf['name'];
         if (array_key_exists($name, $this->configlocks)) {
             debugging('Duplicate cache lock detected. This should never happen.', DEBUG_DEVELOPER);
             continue;
         }
         $conf['default'] = !empty($conf['default']);
         if ($defaultlock === null || $conf['default']) {
             $defaultlock = $name;
         }
         $this->configlocks[$name] = $conf;
     }
     // Filter the stores.
     $availableplugins = cache_helper::early_get_cache_plugins();
     foreach ($configuration['stores'] as $store) {
         if (!is_array($store) || !array_key_exists('name', $store) || !array_key_exists('plugin', $store)) {
             // Not a valid instance configuration.
             debugging('Invalid cache store in config. Missing name or plugin.', DEBUG_DEVELOPER);
             continue;
         }
         $plugin = $store['plugin'];
         $class = 'cachestore_' . $plugin;
         $exists = array_key_exists($plugin, $availableplugins);
         if (!$exists) {
             // Not a valid plugin, or has been uninstalled, just skip it an carry on.
             debugging('Invalid cache store in config. Not an available plugin.', DEBUG_DEVELOPER);
             continue;
         }
         $file = $CFG->dirroot . '/cache/stores/' . $plugin . '/lib.php';
         if (!class_exists($class) && file_exists($file)) {
             require_once $file;
         }
         if (!class_exists($class)) {
             continue;
         }
         if (!array_key_exists('cache_store', class_parents($class))) {
             continue;
         }
         if (!array_key_exists('configuration', $store) || !is_array($store['configuration'])) {
             $store['configuration'] = array();
         }
         $store['class'] = $class;
         $store['default'] = !empty($store['default']);
         if (!array_key_exists('lock', $store) || !array_key_exists($store['lock'], $this->configlocks)) {
             $store['lock'] = $defaultlock;
         }
         $this->configstores[$store['name']] = $store;
     }
     // Filter the definitions.
     foreach ($configuration['definitions'] as $id => $conf) {
         if (!is_array($conf)) {
             // Something is very wrong here.
             continue;
         }
         if (!array_key_exists('mode', $conf) || !array_key_exists('component', $conf) || !array_key_exists('area', $conf)) {
             // Not a valid definition configuration.
             continue;
         }
         if (array_key_exists($id, $this->configdefinitions)) {
             debugging('Duplicate cache definition detected. This should never happen.', DEBUG_DEVELOPER);
             continue;
         }
         $conf['mode'] = (int) $conf['mode'];
         if ($conf['mode'] < cache_store::MODE_APPLICATION || $conf['mode'] > cache_store::MODE_REQUEST) {
             // Invalid cache mode used for the definition.
             continue;
         }
//.........這裏部分代碼省略.........
開發者ID:Burick,項目名稱:moodle,代碼行數:101,代碼來源:config.php


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