当前位置: 首页>>代码示例>>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;未经允许,请勿转载。