本文整理匯總了PHP中cache_definition::get_requirements_bin方法的典型用法代碼示例。如果您正苦於以下問題:PHP cache_definition::get_requirements_bin方法的具體用法?PHP cache_definition::get_requirements_bin怎麽用?PHP cache_definition::get_requirements_bin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cache_definition
的用法示例。
在下文中一共展示了cache_definition::get_requirements_bin方法的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;
}