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


PHP cache_helper::get_stores_suitable_for_definition方法代码示例

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


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

示例1: create_cache

 /**
  * Common public method to create a cache instance given a definition.
  *
  * This is used by the static make methods.
  *
  * @param cache_definition $definition
  * @return cache_application|cache_session|cache_store
  * @throws coding_exception
  */
 public function create_cache(cache_definition $definition)
 {
     $class = $definition->get_cache_class();
     $stores = cache_helper::get_stores_suitable_for_definition($definition);
     foreach ($stores as $key => $store) {
         if (!$store::are_requirements_met()) {
             unset($stores[$key]);
         }
     }
     if (count($stores) === 0) {
         // Hmm still no stores, better provide a dummy store to mimic functionality. The dev will be none the wiser.
         $stores[] = $this->create_dummy_store($definition);
     }
     $loader = null;
     if ($definition->has_data_source()) {
         $loader = $definition->get_data_source();
     }
     while (($store = array_pop($stores)) !== null) {
         $loader = new $class($definition, $store, $loader);
     }
     return $loader;
 }
开发者ID:abhilash1994,项目名称:moodle,代码行数:31,代码来源:factory.php

示例2: get_definition_summaries

 /**
  * Returns an array about the definitions. All the information a renderer needs.
  * @return array
  */
 public static function get_definition_summaries()
 {
     $factory = cache_factory::instance();
     $config = $factory->create_config_instance();
     $storenames = array();
     foreach ($config->get_all_stores() as $key => $store) {
         if (!empty($store['default'])) {
             $storenames[$key] = new lang_string('store_' . $key, 'cache');
         } else {
             $storenames[$store['name']] = $store['name'];
         }
     }
     /* @var cache_definition[] $definitions */
     $definitions = array();
     foreach ($config->get_definitions() as $key => $definition) {
         $definitions[$key] = cache_definition::load($definition['component'] . '/' . $definition['area'], $definition);
     }
     foreach ($definitions as $id => $definition) {
         $mappings = array();
         foreach (cache_helper::get_stores_suitable_for_definition($definition) as $store) {
             $mappings[] = $storenames[$store->my_name()];
         }
         $return[$id] = array('id' => $id, 'name' => $definition->get_name(), 'mode' => $definition->get_mode(), 'component' => $definition->get_component(), 'area' => $definition->get_area(), 'mappings' => $mappings, 'canuselocalstore' => $definition->can_use_localstore(), 'sharingoptions' => self::get_definition_sharing_options($definition->get_sharing_options(), false), 'selectedsharingoption' => self::get_definition_sharing_options($definition->get_selected_sharing_option(), true), 'userinputsharingkey' => $definition->get_user_input_sharing_key());
     }
     return $return;
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:30,代码来源:locallib.php


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