本文整理匯總了PHP中cache_helper::get_stores_suitable_for_mode_default方法的典型用法代碼示例。如果您正苦於以下問題:PHP cache_helper::get_stores_suitable_for_mode_default方法的具體用法?PHP cache_helper::get_stores_suitable_for_mode_default怎麽用?PHP cache_helper::get_stores_suitable_for_mode_default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cache_helper
的用法示例。
在下文中一共展示了cache_helper::get_stores_suitable_for_mode_default方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: get_expected_application_cache_store
/**
* Returns the expected application cache store.
* @return string
*/
protected function get_expected_application_cache_store()
{
global $CFG;
$expected = 'cachestore_file';
// Verify if we are using any of the available ways to use a different application store within tests.
if (defined('TEST_CACHE_USING_APPLICATION_STORE') && preg_match('#[a-zA-Z][a-zA-Z0-9_]*#', TEST_CACHE_USING_APPLICATION_STORE)) {
// 1st way. Using some of the testing servers.
$expected = 'cachestore_' . (string) TEST_CACHE_USING_APPLICATION_STORE;
} else {
if (defined('TEST_CACHE_USING_ALT_CACHE_CONFIG_PATH') && TEST_CACHE_USING_ALT_CACHE_CONFIG_PATH && !empty($CFG->altcacheconfigpath)) {
// 2nd way. Using an alternative configuration.
$defaultstores = cache_helper::get_stores_suitable_for_mode_default();
$instance = cache_config::instance();
// Iterate over defined mode mappings until we get an application one not being the default.
foreach ($instance->get_mode_mappings() as $mapping) {
// If the store is not for application mode, ignore.
if ($mapping['mode'] !== cache_store::MODE_APPLICATION) {
continue;
}
// If the store matches some default mapping store name, ignore.
if (array_key_exists($mapping['store'], $defaultstores) && !empty($defaultstores[$mapping['store']]['default'])) {
continue;
}
// Arrived here, have found an application mode store not being the default mapped one (file),
// that's the one we are using in the configuration for sure.
$expected = 'cachestore_' . $mapping['store'];
}
}
}
return $expected;
}
示例2: get_default_mode_stores
/**
* Get the default stores for all modes.
*
* @return array An array containing sub-arrays, one for each mode.
*/
public static function get_default_mode_stores()
{
global $OUTPUT;
$instance = cache_config::instance();
$adequatestores = cache_helper::get_stores_suitable_for_mode_default();
$icon = new pix_icon('i/warning', new lang_string('inadequatestoreformapping', 'cache'));
$storenames = array();
foreach ($instance->get_all_stores() as $key => $store) {
if (!empty($store['default'])) {
$storenames[$key] = new lang_string('store_' . $key, 'cache');
}
}
$modemappings = array(cache_store::MODE_APPLICATION => array(), cache_store::MODE_SESSION => array(), cache_store::MODE_REQUEST => array());
foreach ($instance->get_mode_mappings() as $mapping) {
$mode = $mapping['mode'];
if (!array_key_exists($mode, $modemappings)) {
debugging('Unknown mode in cache store mode mappings', DEBUG_DEVELOPER);
continue;
}
if (array_key_exists($mapping['store'], $storenames)) {
$modemappings[$mode][$mapping['store']] = $storenames[$mapping['store']];
} else {
$modemappings[$mode][$mapping['store']] = $mapping['store'];
}
if (!array_key_exists($mapping['store'], $adequatestores)) {
$modemappings[$mode][$mapping['store']] = $modemappings[$mode][$mapping['store']] . ' ' . $OUTPUT->render($icon);
}
}
return $modemappings;
}