Merge branch 'wip-MDL-36819-m24-rb' of git://github.com/samhemelryk/moodle
This commit is contained in:
Vendored
+29
@@ -338,6 +338,35 @@ interface cache_is_key_aware {
|
||||
public function has_all(array $keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache store feature: configurable.
|
||||
*
|
||||
* This feature should be implemented by all cache stores that are configurable when adding an instance.
|
||||
* It requires the implementation of methods required to convert form data into the a configuration array for the
|
||||
* store instance, and then the reverse converting configuration data into an array that can be used to set the
|
||||
* data for the edit form.
|
||||
*
|
||||
* Can be implemented by classes already implementing cache_store.
|
||||
*/
|
||||
interface cache_is_configurable {
|
||||
|
||||
/**
|
||||
* Given the data from the add instance form this function creates a configuration array.
|
||||
*
|
||||
* @param stdClass $data
|
||||
* @return array
|
||||
*/
|
||||
public static function config_get_configuration_array($data);
|
||||
|
||||
/**
|
||||
* Allows the cache store to set its data against the edit form before it is shown to the user.
|
||||
*
|
||||
* @param moodleform $editform
|
||||
* @param array $config
|
||||
*/
|
||||
public static function config_set_edit_form_data(moodleform $editform, array $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache Data Source.
|
||||
*
|
||||
|
||||
Vendored
+3
-4
@@ -790,7 +790,7 @@ abstract class cache_administration_helper extends cache_helper {
|
||||
// If it has a customised add instance form then it is going to want to.
|
||||
$storeclass = 'cachestore_'.$plugin;
|
||||
$storedata = $stores[$store];
|
||||
if (array_key_exists('configuration', $storedata) && method_exists($storeclass, 'config_set_edit_form_data')) {
|
||||
if (array_key_exists('configuration', $storedata) && array_key_exists('cache_is_configurable', class_implements($storeclass))) {
|
||||
$storeclass::config_set_edit_form_data($editform, $storedata['configuration']);
|
||||
}
|
||||
return $editform;
|
||||
@@ -848,12 +848,11 @@ abstract class cache_administration_helper extends cache_helper {
|
||||
}
|
||||
require_once($file);
|
||||
$class = 'cachestore_'.$data->plugin;
|
||||
$method = 'config_get_configuration_array';
|
||||
if (!class_exists($class)) {
|
||||
throw new coding_exception('Invalid cache plugin provided.');
|
||||
}
|
||||
if (method_exists($class, $method)) {
|
||||
return call_user_func(array($class, $method), $data);
|
||||
if (array_key_exists('cache_is_configurable', class_implements($class))) {
|
||||
return $class::config_get_configuration_array($data);
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -37,7 +37,7 @@
|
||||
* @copyright 2012 Sam Hemelryk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class cachestore_file extends cache_store implements cache_is_key_aware {
|
||||
class cachestore_file extends cache_store implements cache_is_key_aware, cache_is_configurable {
|
||||
|
||||
/**
|
||||
* The name of the store.
|
||||
|
||||
Vendored
+1
-1
@@ -37,7 +37,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @copyright 2012 Sam Hemelryk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class cachestore_memcache extends cache_store {
|
||||
class cachestore_memcache extends cache_store implements cache_is_configurable {
|
||||
|
||||
/**
|
||||
* The name of the store
|
||||
|
||||
Vendored
+1
-2
@@ -43,8 +43,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @copyright 2012 Sam Hemelryk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class cachestore_memcached extends cache_store {
|
||||
|
||||
class cachestore_memcached extends cache_store implements cache_is_configurable {
|
||||
/**
|
||||
* The name of the store
|
||||
* @var store
|
||||
|
||||
Vendored
+1
-1
@@ -37,7 +37,7 @@ defined('MOODLE_INTERNAL') || die();
|
||||
* @copyright 2012 Sam Hemelryk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class cachestore_mongodb extends cache_store {
|
||||
class cachestore_mongodb extends cache_store implements cache_is_configurable {
|
||||
|
||||
/**
|
||||
* The name of the store
|
||||
|
||||
Reference in New Issue
Block a user