| Línea 12... |
Línea 12... |
| 12 |
// GNU General Public License for more details.
|
12 |
// GNU General Public License for more details.
|
| 13 |
//
|
13 |
//
|
| 14 |
// You should have received a copy of the GNU General Public License
|
14 |
// You should have received a copy of the GNU General Public License
|
| 15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
| Línea 16... |
Línea -... |
| 16 |
|
- |
|
| 17 |
/**
|
- |
|
| 18 |
* Cache administration helper.
|
- |
|
| 19 |
*
|
- |
|
| 20 |
* This file is part of Moodle's cache API, affectionately called MUC.
|
- |
|
| 21 |
* It contains the components that are requried in order to use caching.
|
- |
|
| 22 |
*
|
- |
|
| 23 |
* @package core
|
- |
|
| 24 |
* @category cache
|
- |
|
| 25 |
* @author Peter Burnett <peterburnett@catalyst-au.net>
|
- |
|
| 26 |
* @copyright 2020 Catalyst IT
|
- |
|
| 27 |
* @copyright 2012 Sam Hemelryk
|
- |
|
| 28 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
- |
|
| 29 |
*/
|
- |
|
| 30 |
|
16 |
|
| Línea 31... |
Línea 17... |
| 31 |
namespace core_cache;
|
17 |
namespace core_cache;
|
| 32 |
|
18 |
|
| - |
|
19 |
use core_component;
|
| Línea 33... |
Línea 20... |
| 33 |
defined('MOODLE_INTERNAL') || die();
|
20 |
use core\output\pix_icon;
|
| 34 |
use cache_helper, cache_store, cache_config, cache_factory, cache_definition;
|
21 |
use lang_string;
|
| 35 |
|
22 |
|
| 36 |
/**
|
23 |
/**
|
| 37 |
* Administration helper base class.
|
24 |
* Administration helper base class.
|
| 38 |
*
|
25 |
*
|
| 39 |
* Defines abstract methods for a subclass to define the admin page.
|
26 |
* Defines abstract methods for a subclass to define the admin page.
|
| 40 |
*
|
27 |
*
|
| 41 |
* @package core
|
28 |
* @package core_cache
|
| 42 |
* @category cache
|
29 |
* @category cache
|
| 43 |
* @author Peter Burnett <peterburnett@catalyst-au.net>
|
30 |
* @author Peter Burnett <peterburnett@catalyst-au.net>
|
| 44 |
* @copyright 2020 Catalyst IT
|
31 |
* @copyright 2020 Catalyst IT
|
| 45 |
* @copyright 2012 Sam Hemelryk
|
32 |
* @copyright 2012 Sam Hemelryk
|
| 46 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
- |
|
| 47 |
*/
|
33 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
| 48 |
abstract class administration_helper extends cache_helper {
|
34 |
*/
|
| 49 |
|
35 |
abstract class administration_helper extends helper {
|
| 50 |
/**
|
36 |
/**
|
| 51 |
* Returns an array containing all of the information about stores a renderer needs.
|
37 |
* Returns an array containing all of the information about stores a renderer needs.
|
| 52 |
* @return array
|
38 |
* @return array
|
| 53 |
*/
|
39 |
*/
|
| 54 |
public static function get_store_instance_summaries(): array {
|
40 |
public static function get_store_instance_summaries(): array {
|
| 55 |
$return = array();
|
41 |
$return = [];
|
| 56 |
$default = array();
|
42 |
$default = [];
|
| 57 |
$instance = \cache_config::instance();
|
43 |
$instance = config::instance();
|
| 58 |
$stores = $instance->get_all_stores();
|
44 |
$stores = $instance->get_all_stores();
|
| 59 |
$locks = $instance->get_locks();
|
45 |
$locks = $instance->get_locks();
|
| 60 |
foreach ($stores as $name => $details) {
|
46 |
foreach ($stores as $name => $details) {
|
| 61 |
$class = $details['class'];
|
47 |
$class = $details['class'];
|
| 62 |
$store = false;
|
48 |
$store = false;
|
| 63 |
if ($class::are_requirements_met()) {
|
49 |
if ($class::are_requirements_met()) {
|
| 64 |
$store = new $class($details['name'], $details['configuration']);
|
50 |
$store = new $class($details['name'], $details['configuration']);
|
| 65 |
}
|
51 |
}
|
| 66 |
$lock = (isset($details['lock'])) ? $locks[$details['lock']] : $instance->get_default_lock();
|
52 |
$lock = (isset($details['lock'])) ? $locks[$details['lock']] : $instance->get_default_lock();
|
| 67 |
$record = array(
|
53 |
$record = [
|
| 68 |
'name' => $name,
|
54 |
'name' => $name,
|
| 69 |
'plugin' => $details['plugin'],
|
55 |
'plugin' => $details['plugin'],
|
| 70 |
'default' => $details['default'],
|
56 |
'default' => $details['default'],
|
| 71 |
'isready' => $store ? $store->is_ready() : false,
|
57 |
'isready' => $store ? $store->is_ready() : false,
|
| 72 |
'requirementsmet' => $class::are_requirements_met(),
|
58 |
'requirementsmet' => $class::are_requirements_met(),
|
| 73 |
'mappings' => 0,
|
59 |
'mappings' => 0,
|
| 74 |
'lock' => $lock,
|
60 |
'lock' => $lock,
|
| 75 |
'modes' => array(
|
61 |
'modes' => [
|
| 76 |
cache_store::MODE_APPLICATION =>
|
62 |
store::MODE_APPLICATION =>
|
| 77 |
($class::get_supported_modes($return) & cache_store::MODE_APPLICATION) == cache_store::MODE_APPLICATION,
|
63 |
($class::get_supported_modes($return) & store::MODE_APPLICATION) == store::MODE_APPLICATION,
|
| 78 |
cache_store::MODE_SESSION =>
|
64 |
store::MODE_SESSION =>
|
| 79 |
($class::get_supported_modes($return) & cache_store::MODE_SESSION) == cache_store::MODE_SESSION,
|
65 |
($class::get_supported_modes($return) & store::MODE_SESSION) == store::MODE_SESSION,
|
| 80 |
cache_store::MODE_REQUEST =>
|
66 |
store::MODE_REQUEST =>
|
| 81 |
($class::get_supported_modes($return) & cache_store::MODE_REQUEST) == cache_store::MODE_REQUEST,
|
67 |
($class::get_supported_modes($return) & store::MODE_REQUEST) == store::MODE_REQUEST,
|
| 82 |
),
|
68 |
],
|
| 83 |
'supports' => array(
|
69 |
'supports' => [
|
| 84 |
'multipleidentifiers' => $store ? $store->supports_multiple_identifiers() : false,
|
70 |
'multipleidentifiers' => $store ? $store->supports_multiple_identifiers() : false,
|
| 85 |
'dataguarantee' => $store ? $store->supports_data_guarantee() : false,
|
71 |
'dataguarantee' => $store ? $store->supports_data_guarantee() : false,
|
| 86 |
'nativettl' => $store ? $store->supports_native_ttl() : false,
|
72 |
'nativettl' => $store ? $store->supports_native_ttl() : false,
|
| 87 |
'nativelocking' => ($store instanceof \cache_is_lockable),
|
73 |
'nativelocking' => ($store instanceof lockable_cache_interface),
|
| 88 |
'keyawareness' => ($store instanceof \cache_is_key_aware),
|
74 |
'keyawareness' => ($store instanceof key_aware_cache_interface),
|
| 89 |
'searchable' => ($store instanceof \cache_is_searchable)
|
75 |
'searchable' => ($store instanceof searchable_cache_interface),
|
| 90 |
),
|
76 |
],
|
| 91 |
'warnings' => $store ? $store->get_warnings() : array()
|
77 |
'warnings' => $store ? $store->get_warnings() : [],
|
| 92 |
);
|
78 |
];
|
| 93 |
if (empty($details['default'])) {
|
79 |
if (empty($details['default'])) {
|
| 94 |
$return[$name] = $record;
|
80 |
$return[$name] = $record;
|
| Línea 134... |
Línea 120... |
| 134 |
*
|
120 |
*
|
| 135 |
* @return array for each store, an array containing various information about each store.
|
121 |
* @return array for each store, an array containing various information about each store.
|
| 136 |
* See the code below for details
|
122 |
* See the code below for details
|
| 137 |
*/
|
123 |
*/
|
| 138 |
public static function get_store_plugin_summaries(): array {
|
124 |
public static function get_store_plugin_summaries(): array {
|
| 139 |
$return = array();
|
125 |
$return = [];
|
| 140 |
$plugins = \core_component::get_plugin_list_with_file('cachestore', 'lib.php', true);
|
126 |
$plugins = \core_component::get_plugin_list_with_file('cachestore', 'lib.php', true);
|
| 141 |
foreach ($plugins as $plugin => $path) {
|
127 |
foreach ($plugins as $plugin => $path) {
|
| 142 |
$class = 'cachestore_'.$plugin;
|
128 |
$class = 'cachestore_' . $plugin;
|
| 143 |
$return[$plugin] = array(
|
129 |
$return[$plugin] = [
|
| 144 |
'name' => get_string('pluginname', 'cachestore_'.$plugin),
|
130 |
'name' => get_string('pluginname', 'cachestore_' . $plugin),
|
| 145 |
'requirementsmet' => $class::are_requirements_met(),
|
131 |
'requirementsmet' => $class::are_requirements_met(),
|
| 146 |
'instances' => 0,
|
132 |
'instances' => 0,
|
| 147 |
'modes' => array(
|
133 |
'modes' => [
|
| 148 |
cache_store::MODE_APPLICATION => ($class::get_supported_modes() & cache_store::MODE_APPLICATION),
|
134 |
store::MODE_APPLICATION => ($class::get_supported_modes() & store::MODE_APPLICATION),
|
| 149 |
cache_store::MODE_SESSION => ($class::get_supported_modes() & cache_store::MODE_SESSION),
|
135 |
store::MODE_SESSION => ($class::get_supported_modes() & store::MODE_SESSION),
|
| 150 |
cache_store::MODE_REQUEST => ($class::get_supported_modes() & cache_store::MODE_REQUEST),
|
136 |
store::MODE_REQUEST => ($class::get_supported_modes() & store::MODE_REQUEST),
|
| 151 |
),
|
137 |
],
|
| 152 |
'supports' => array(
|
138 |
'supports' => [
|
| 153 |
'multipleidentifiers' => ($class::get_supported_features() & cache_store::SUPPORTS_MULTIPLE_IDENTIFIERS),
|
139 |
'multipleidentifiers' => ($class::get_supported_features() & store::SUPPORTS_MULTIPLE_IDENTIFIERS),
|
| 154 |
'dataguarantee' => ($class::get_supported_features() & cache_store::SUPPORTS_DATA_GUARANTEE),
|
140 |
'dataguarantee' => ($class::get_supported_features() & store::SUPPORTS_DATA_GUARANTEE),
|
| 155 |
'nativettl' => ($class::get_supported_features() & cache_store::SUPPORTS_NATIVE_TTL),
|
141 |
'nativettl' => ($class::get_supported_features() & store::SUPPORTS_NATIVE_TTL),
|
| 156 |
'nativelocking' => (in_array('cache_is_lockable', class_implements($class))),
|
142 |
'nativelocking' => (in_array(lockable_cache_interface::class, class_implements($class))),
|
| 157 |
'keyawareness' => (array_key_exists('cache_is_key_aware', class_implements($class))),
|
143 |
'keyawareness' => (array_key_exists(key_aware_cache_interface::class, class_implements($class))),
|
| 158 |
),
|
144 |
],
|
| 159 |
'canaddinstance' => ($class::can_add_instance() && $class::are_requirements_met())
|
145 |
'canaddinstance' => ($class::can_add_instance() && $class::are_requirements_met()),
|
| 160 |
);
|
146 |
];
|
| 161 |
}
|
147 |
}
|
| Línea 162... |
Línea 148... |
| 162 |
|
148 |
|
| 163 |
$instance = cache_config::instance();
|
149 |
$instance = config::instance();
|
| 164 |
$stores = $instance->get_all_stores();
|
150 |
$stores = $instance->get_all_stores();
|
| 165 |
foreach ($stores as $store) {
|
151 |
foreach ($stores as $store) {
|
| 166 |
$plugin = $store['plugin'];
|
152 |
$plugin = $store['plugin'];
|
| 167 |
if (array_key_exists($plugin, $return)) {
|
153 |
if (array_key_exists($plugin, $return)) {
|
| Línea 177... |
Línea 163... |
| 177 |
*
|
163 |
*
|
| 178 |
* @return array for each store, an array containing various information about each store.
|
164 |
* @return array for each store, an array containing various information about each store.
|
| 179 |
* See the code below for details
|
165 |
* See the code below for details
|
| 180 |
*/
|
166 |
*/
|
| 181 |
public static function get_definition_summaries(): array {
|
167 |
public static function get_definition_summaries(): array {
|
| 182 |
$factory = cache_factory::instance();
|
168 |
$factory = factory::instance();
|
| 183 |
$config = $factory->create_config_instance();
|
169 |
$config = $factory->create_config_instance();
|
| 184 |
$storenames = array();
|
170 |
$storenames = [];
|
| 185 |
foreach ($config->get_all_stores() as $key => $store) {
|
171 |
foreach ($config->get_all_stores() as $key => $store) {
|
| 186 |
if (!empty($store['default'])) {
|
172 |
if (!empty($store['default'])) {
|
| 187 |
$storenames[$key] = new \lang_string('store_'.$key, 'cache');
|
173 |
$storenames[$key] = new lang_string('store_' . $key, 'cache');
|
| 188 |
} else {
|
174 |
} else {
|
| 189 |
$storenames[$store['name']] = $store['name'];
|
175 |
$storenames[$store['name']] = $store['name'];
|
| 190 |
}
|
176 |
}
|
| 191 |
}
|
177 |
}
|
| 192 |
/* @var cache_definition[] $definitions */
|
178 |
/* @var definition[] $definitions */
|
| 193 |
$definitions = [];
|
179 |
$definitions = [];
|
| 194 |
$return = [];
|
180 |
$return = [];
|
| 195 |
foreach ($config->get_definitions() as $key => $definition) {
|
181 |
foreach ($config->get_definitions() as $key => $definition) {
|
| 196 |
$definitions[$key] = cache_definition::load($definition['component'].'/'.$definition['area'], $definition);
|
182 |
$definitions[$key] = definition::load($definition['component'] . '/' . $definition['area'], $definition);
|
| 197 |
}
|
183 |
}
|
| 198 |
foreach ($definitions as $id => $definition) {
|
184 |
foreach ($definitions as $id => $definition) {
|
| 199 |
$mappings = array();
|
185 |
$mappings = [];
|
| 200 |
foreach (cache_helper::get_stores_suitable_for_definition($definition) as $store) {
|
186 |
foreach (helper::get_stores_suitable_for_definition($definition) as $store) {
|
| 201 |
$mappings[] = $storenames[$store->my_name()];
|
187 |
$mappings[] = $storenames[$store->my_name()];
|
| 202 |
}
|
188 |
}
|
| 203 |
$return[$id] = array(
|
189 |
$return[$id] = [
|
| 204 |
'id' => $id,
|
190 |
'id' => $id,
|
| 205 |
'name' => $definition->get_name(),
|
191 |
'name' => $definition->get_name(),
|
| 206 |
'mode' => $definition->get_mode(),
|
192 |
'mode' => $definition->get_mode(),
|
| 207 |
'component' => $definition->get_component(),
|
193 |
'component' => $definition->get_component(),
|
| 208 |
'area' => $definition->get_area(),
|
194 |
'area' => $definition->get_area(),
|
| 209 |
'mappings' => $mappings,
|
195 |
'mappings' => $mappings,
|
| 210 |
'canuselocalstore' => $definition->can_use_localstore(),
|
196 |
'canuselocalstore' => $definition->can_use_localstore(),
|
| 211 |
'sharingoptions' => self::get_definition_sharing_options($definition->get_sharing_options(), false),
|
197 |
'sharingoptions' => self::get_definition_sharing_options($definition->get_sharing_options(), false),
|
| 212 |
'selectedsharingoption' => self::get_definition_sharing_options($definition->get_selected_sharing_option(), true),
|
198 |
'selectedsharingoption' => self::get_definition_sharing_options($definition->get_selected_sharing_option(), true),
|
| 213 |
'userinputsharingkey' => $definition->get_user_input_sharing_key()
|
199 |
'userinputsharingkey' => $definition->get_user_input_sharing_key(),
|
| 214 |
);
|
200 |
];
|
| 215 |
}
|
201 |
}
|
| 216 |
return $return;
|
202 |
return $return;
|
| 217 |
}
|
203 |
}
|
| Línea 218... |
Línea 204... |
| 218 |
|
204 |
|
| Línea 221... |
Línea 207... |
| 221 |
*
|
207 |
*
|
| 222 |
* @return array An array containing sub-arrays, one for each mode.
|
208 |
* @return array An array containing sub-arrays, one for each mode.
|
| 223 |
*/
|
209 |
*/
|
| 224 |
public static function get_default_mode_stores(): array {
|
210 |
public static function get_default_mode_stores(): array {
|
| 225 |
global $OUTPUT;
|
211 |
global $OUTPUT;
|
| 226 |
$instance = cache_config::instance();
|
212 |
$instance = config::instance();
|
| 227 |
$adequatestores = cache_helper::get_stores_suitable_for_mode_default();
|
213 |
$adequatestores = helper::get_stores_suitable_for_mode_default();
|
| 228 |
$icon = new \pix_icon('i/warning', new \lang_string('inadequatestoreformapping', 'cache'));
|
214 |
$icon = new pix_icon('i/warning', new lang_string('inadequatestoreformapping', 'cache'));
|
| 229 |
$storenames = array();
|
215 |
$storenames = [];
|
| 230 |
foreach ($instance->get_all_stores() as $key => $store) {
|
216 |
foreach ($instance->get_all_stores() as $key => $store) {
|
| 231 |
if (!empty($store['default'])) {
|
217 |
if (!empty($store['default'])) {
|
| 232 |
$storenames[$key] = new \lang_string('store_'.$key, 'cache');
|
218 |
$storenames[$key] = new lang_string('store_' . $key, 'cache');
|
| 233 |
}
|
219 |
}
|
| 234 |
}
|
220 |
}
|
| 235 |
$modemappings = array(
|
221 |
$modemappings = [
|
| 236 |
cache_store::MODE_APPLICATION => array(),
|
222 |
store::MODE_APPLICATION => [],
|
| 237 |
cache_store::MODE_SESSION => array(),
|
223 |
store::MODE_SESSION => [],
|
| 238 |
cache_store::MODE_REQUEST => array(),
|
224 |
store::MODE_REQUEST => [],
|
| 239 |
);
|
225 |
];
|
| 240 |
foreach ($instance->get_mode_mappings() as $mapping) {
|
226 |
foreach ($instance->get_mode_mappings() as $mapping) {
|
| 241 |
$mode = $mapping['mode'];
|
227 |
$mode = $mapping['mode'];
|
| 242 |
if (!array_key_exists($mode, $modemappings)) {
|
228 |
if (!array_key_exists($mode, $modemappings)) {
|
| 243 |
debugging('Unknown mode in cache store mode mappings', DEBUG_DEVELOPER);
|
229 |
debugging('Unknown mode in cache store mode mappings', DEBUG_DEVELOPER);
|
| 244 |
continue;
|
230 |
continue;
|
| Línea 247... |
Línea 233... |
| 247 |
$modemappings[$mode][$mapping['store']] = $storenames[$mapping['store']];
|
233 |
$modemappings[$mode][$mapping['store']] = $storenames[$mapping['store']];
|
| 248 |
} else {
|
234 |
} else {
|
| 249 |
$modemappings[$mode][$mapping['store']] = $mapping['store'];
|
235 |
$modemappings[$mode][$mapping['store']] = $mapping['store'];
|
| 250 |
}
|
236 |
}
|
| 251 |
if (!array_key_exists($mapping['store'], $adequatestores)) {
|
237 |
if (!array_key_exists($mapping['store'], $adequatestores)) {
|
| 252 |
$modemappings[$mode][$mapping['store']] = $modemappings[$mode][$mapping['store']].' '.$OUTPUT->render($icon);
|
238 |
$modemappings[$mode][$mapping['store']] = $modemappings[$mode][$mapping['store']] . ' ' . $OUTPUT->render($icon);
|
| 253 |
}
|
239 |
}
|
| 254 |
}
|
240 |
}
|
| 255 |
return $modemappings;
|
241 |
return $modemappings;
|
| 256 |
}
|
242 |
}
|
| Línea 259... |
Línea 245... |
| 259 |
* Returns an array summarising the locks available in the system.
|
245 |
* Returns an array summarising the locks available in the system.
|
| 260 |
*
|
246 |
*
|
| 261 |
* @return array array of lock summaries.
|
247 |
* @return array array of lock summaries.
|
| 262 |
*/
|
248 |
*/
|
| 263 |
public static function get_lock_summaries(): array {
|
249 |
public static function get_lock_summaries(): array {
|
| 264 |
$locks = array();
|
250 |
$locks = [];
|
| 265 |
$instance = cache_config::instance();
|
251 |
$instance = config::instance();
|
| 266 |
$stores = $instance->get_all_stores();
|
252 |
$stores = $instance->get_all_stores();
|
| 267 |
foreach ($instance->get_locks() as $lock) {
|
253 |
foreach ($instance->get_locks() as $lock) {
|
| 268 |
$default = !empty($lock['default']);
|
254 |
$default = !empty($lock['default']);
|
| 269 |
if ($default) {
|
255 |
if ($default) {
|
| 270 |
$name = new \lang_string($lock['name'], 'cache');
|
256 |
$name = new lang_string($lock['name'], 'cache');
|
| 271 |
} else {
|
257 |
} else {
|
| 272 |
$name = $lock['name'];
|
258 |
$name = $lock['name'];
|
| 273 |
}
|
259 |
}
|
| 274 |
$uses = 0;
|
260 |
$uses = 0;
|
| 275 |
foreach ($stores as $store) {
|
261 |
foreach ($stores as $store) {
|
| 276 |
if (!empty($store['lock']) && $store['lock'] === $lock['name']) {
|
262 |
if (!empty($store['lock']) && $store['lock'] === $lock['name']) {
|
| 277 |
$uses++;
|
263 |
$uses++;
|
| 278 |
}
|
264 |
}
|
| 279 |
}
|
265 |
}
|
| 280 |
$lockdata = array(
|
266 |
$lockdata = [
|
| 281 |
'name' => $name,
|
267 |
'name' => $name,
|
| 282 |
'default' => $default,
|
268 |
'default' => $default,
|
| 283 |
'uses' => $uses,
|
269 |
'uses' => $uses,
|
| 284 |
'type' => get_string('pluginname', $lock['type'])
|
270 |
'type' => get_string('pluginname', $lock['type']),
|
| 285 |
);
|
271 |
];
|
| 286 |
$locks[$lock['name']] = $lockdata;
|
272 |
$locks[$lock['name']] = $lockdata;
|
| 287 |
}
|
273 |
}
|
| 288 |
return $locks;
|
274 |
return $locks;
|
| 289 |
}
|
275 |
}
|
| Línea 294... |
Línea 280... |
| 294 |
* @param int $sharingoption The sharing option hash to get strings for.
|
280 |
* @param int $sharingoption The sharing option hash to get strings for.
|
| 295 |
* @param bool $isselectedoptions Set to true if the strings will be used to view the selected options.
|
281 |
* @param bool $isselectedoptions Set to true if the strings will be used to view the selected options.
|
| 296 |
* @return array An array of lang_string's.
|
282 |
* @return array An array of lang_string's.
|
| 297 |
*/
|
283 |
*/
|
| 298 |
public static function get_definition_sharing_options(int $sharingoption, bool $isselectedoptions = true): array {
|
284 |
public static function get_definition_sharing_options(int $sharingoption, bool $isselectedoptions = true): array {
|
| 299 |
$options = array();
|
285 |
$options = [];
|
| 300 |
$prefix = ($isselectedoptions) ? 'sharingselected' : 'sharing';
|
286 |
$prefix = ($isselectedoptions) ? 'sharingselected' : 'sharing';
|
| 301 |
if ($sharingoption & cache_definition::SHARING_ALL) {
|
287 |
if ($sharingoption & definition::SHARING_ALL) {
|
| 302 |
$options[cache_definition::SHARING_ALL] = new \lang_string($prefix.'_all', 'cache');
|
288 |
$options[definition::SHARING_ALL] = new lang_string($prefix . '_all', 'cache');
|
| 303 |
}
|
289 |
}
|
| 304 |
if ($sharingoption & cache_definition::SHARING_SITEID) {
|
290 |
if ($sharingoption & definition::SHARING_SITEID) {
|
| 305 |
$options[cache_definition::SHARING_SITEID] = new \lang_string($prefix.'_siteid', 'cache');
|
291 |
$options[definition::SHARING_SITEID] = new lang_string($prefix . '_siteid', 'cache');
|
| 306 |
}
|
292 |
}
|
| 307 |
if ($sharingoption & cache_definition::SHARING_VERSION) {
|
293 |
if ($sharingoption & definition::SHARING_VERSION) {
|
| 308 |
$options[cache_definition::SHARING_VERSION] = new \lang_string($prefix.'_version', 'cache');
|
294 |
$options[definition::SHARING_VERSION] = new lang_string($prefix . '_version', 'cache');
|
| 309 |
}
|
295 |
}
|
| 310 |
if ($sharingoption & cache_definition::SHARING_INPUT) {
|
296 |
if ($sharingoption & definition::SHARING_INPUT) {
|
| 311 |
$options[cache_definition::SHARING_INPUT] = new \lang_string($prefix.'_input', 'cache');
|
297 |
$options[definition::SHARING_INPUT] = new lang_string($prefix . '_input', 'cache');
|
| 312 |
}
|
298 |
}
|
| 313 |
return $options;
|
299 |
return $options;
|
| 314 |
}
|
300 |
}
|
| Línea 315... |
Línea 301... |
| 315 |
|
301 |
|
| Línea 322... |
Línea 308... |
| 322 |
* 1. An array of currently used stores
|
308 |
* 1. An array of currently used stores
|
| 323 |
* 2. An array of suitable stores
|
309 |
* 2. An array of suitable stores
|
| 324 |
* 3. An array of default stores
|
310 |
* 3. An array of default stores
|
| 325 |
*/
|
311 |
*/
|
| 326 |
public static function get_definition_store_options(string $component, string $area): array {
|
312 |
public static function get_definition_store_options(string $component, string $area): array {
|
| 327 |
$factory = cache_factory::instance();
|
313 |
$factory = factory::instance();
|
| 328 |
$definition = $factory->create_definition($component, $area);
|
314 |
$definition = $factory->create_definition($component, $area);
|
| 329 |
$config = cache_config::instance();
|
315 |
$config = config::instance();
|
| 330 |
$currentstores = $config->get_stores_for_definition($definition);
|
316 |
$currentstores = $config->get_stores_for_definition($definition);
|
| 331 |
$possiblestores = $config->get_stores($definition->get_mode(), $definition->get_requirements_bin());
|
317 |
$possiblestores = $config->get_stores($definition->get_mode(), $definition->get_requirements_bin());
|
| Línea 332... |
Línea 318... |
| 332 |
|
318 |
|
| 333 |
$defaults = array();
|
319 |
$defaults = [];
|
| 334 |
foreach ($currentstores as $key => $store) {
|
320 |
foreach ($currentstores as $key => $store) {
|
| 335 |
if (!empty($store['default'])) {
|
321 |
if (!empty($store['default'])) {
|
| 336 |
$defaults[] = $key;
|
322 |
$defaults[] = $key;
|
| 337 |
unset($currentstores[$key]);
|
323 |
unset($currentstores[$key]);
|
| Línea 341... |
Línea 327... |
| 341 |
if ($store['default']) {
|
327 |
if ($store['default']) {
|
| 342 |
unset($possiblestores[$key]);
|
328 |
unset($possiblestores[$key]);
|
| 343 |
$possiblestores[$key] = $store;
|
329 |
$possiblestores[$key] = $store;
|
| 344 |
}
|
330 |
}
|
| 345 |
}
|
331 |
}
|
| 346 |
return array($currentstores, $possiblestores, $defaults);
|
332 |
return [$currentstores, $possiblestores, $defaults];
|
| 347 |
}
|
333 |
}
|
| Línea 348... |
Línea 334... |
| 348 |
|
334 |
|
| 349 |
/**
|
335 |
/**
|
| 350 |
* This function must be implemented to display options for store plugins.
|
336 |
* This function must be implemented to display options for store plugins.
|
| 351 |
*
|
337 |
*
|
| 352 |
* @param string $name the name of the store plugin.
|
338 |
* @param string $name the name of the store plugin.
|
| 353 |
* @param array $plugindetails array of store plugin details.
|
339 |
* @param array $plugindetails array of store plugin details.
|
| 354 |
* @return array array of actions.
|
340 |
* @return array array of actions.
|
| 355 |
*/
|
341 |
*/
|
| 356 |
public function get_store_plugin_actions(string $name, array $plugindetails): array {
|
342 |
public function get_store_plugin_actions(string $name, array $plugindetails): array {
|
| 357 |
return array();
|
343 |
return [];
|
| Línea 358... |
Línea 344... |
| 358 |
}
|
344 |
}
|
| 359 |
|
345 |
|
| 360 |
/**
|
346 |
/**
|
| 361 |
* This function must be implemented to display options for store instances.
|
347 |
* This function must be implemented to display options for store instances.
|
| 362 |
*
|
348 |
*
|
| 363 |
* @param string $name the store instance name.
|
349 |
* @param string $name the store instance name.
|
| 364 |
* @param array $storedetails array of store instance details.
|
350 |
* @param array $storedetails array of store instance details.
|
| 365 |
* @return array array of actions.
|
351 |
* @return array array of actions.
|
| 366 |
*/
|
352 |
*/
|
| 367 |
public function get_store_instance_actions(string $name, array $storedetails): array {
|
353 |
public function get_store_instance_actions(string $name, array $storedetails): array {
|
| Línea 368... |
Línea 354... |
| 368 |
return array();
|
354 |
return [];
|
| 369 |
}
|
355 |
}
|
| 370 |
|
356 |
|
| 371 |
/**
|
357 |
/**
|
| 372 |
* This function must be implemented to display options for definition mappings.
|
358 |
* This function must be implemented to display options for definition mappings.
|
| 373 |
*
|
359 |
*
|
| 374 |
* @param context $context the context for the definition.
|
360 |
* @param context $context the context for the definition.
|
| 375 |
* @param array $definitionsummary the definition summary.
|
361 |
* @param array $definitionsummary the definition summary.
|
| 376 |
* @return array array of actions.
|
362 |
* @return array array of actions.
|
| 377 |
*/
|
363 |
*/
|
| Línea 378... |
Línea 364... |
| 378 |
public function get_definition_actions(\context $context, array $definitionsummary): array {
|
364 |
public function get_definition_actions(\context $context, array $definitionsummary): array {
|
| 379 |
return array();
|
365 |
return [];
|
| 380 |
}
|
366 |
}
|
| 381 |
|
367 |
|
| 382 |
/**
|
368 |
/**
|
| 383 |
* This function must be implemented to get addable locks.
|
369 |
* This function must be implemented to get addable locks.
|
| 384 |
*
|
370 |
*
|
| 385 |
* @return array array of locks that are addable.
|
371 |
* @return array array of locks that are addable.
|
| Línea 386... |
Línea 372... |
| 386 |
*/
|
372 |
*/
|
| 387 |
public function get_addable_lock_options(): array {
|
373 |
public function get_addable_lock_options(): array {
|
| 388 |
return array();
|
374 |
return [];
|