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


PHP cache_definition::is_for_mappings_only方法代码示例

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


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

示例1: get_stores_for_definition

 /**
  * Gets all of the stores that are to be used for the given definition.
  *
  * @param cache_definition $definition
  * @return array
  */
 public function get_stores_for_definition(cache_definition $definition)
 {
     // Check if MUC has been disabled.
     $factory = cache_factory::instance();
     if ($factory->stores_disabled()) {
         // Yip its been disabled.
         // To facilitate this we are going to always return an empty array of stores to use.
         // This will force all cache instances to use the cachestore_dummy.
         // MUC will still be used essentially so that code using it will still continue to function but because no cache stores
         // are being used interaction with MUC will be purely based around a static var.
         return array();
     }
     $availablestores = $this->get_stores($definition->get_mode(), $definition->get_requirements_bin());
     $stores = array();
     $id = $definition->get_id();
     // Now get any mappings and give them priority.
     foreach ($this->configdefinitionmappings as $mapping) {
         if ($mapping['definition'] !== $id) {
             continue;
         }
         $storename = $mapping['store'];
         if (!array_key_exists($storename, $availablestores)) {
             continue;
         }
         if (array_key_exists($storename, $stores)) {
             $store = $stores[$storename];
             unset($stores[$storename]);
             $stores[$storename] = $store;
         } else {
             $stores[$storename] = $availablestores[$storename];
         }
     }
     if (empty($stores) && !$definition->is_for_mappings_only()) {
         $mode = $definition->get_mode();
         // Load the default stores.
         foreach ($this->configmodemappings as $mapping) {
             if ($mapping['mode'] === $mode && array_key_exists($mapping['store'], $availablestores)) {
                 $store = $availablestores[$mapping['store']];
                 if (empty($store['mappingsonly'])) {
                     $stores[$mapping['store']] = $store;
                 }
             }
         }
     }
     return $stores;
 }
开发者ID:Burick,项目名称:moodle,代码行数:52,代码来源:config.php


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