Permalink
Browse files

MDL-25290 cache: renaming to better separate store plugins from lock …

…plugins
  • Loading branch information...
1 parent 42f2c59 commit 26ce56fddfeda1d93327a62fef0b799497a00849 Sam Hemelryk committed Oct 1, 2012
Showing with 40 additions and 40 deletions.
  1. +7 −7 cache/admin.php
  2. +1 −1 cache/forms.php
  3. +10 −10 cache/locallib.php
  4. +4 −4 cache/renderer.php
  5. +16 −16 cache/tests/locallib_test.php
  6. +2 −2 lang/en/cache.php
View
14 cache/admin.php
@@ -35,8 +35,8 @@
admin_externalpage_setup('cacheconfig');
$context = context_system::instance();
-$stores = cache_administration_helper::get_store_summaries();
-$plugins = cache_administration_helper::get_plugin_summaries();
+$stores = cache_administration_helper::get_store_instance_summaries();
+$plugins = cache_administration_helper::get_store_plugin_summaries();
$definitions = cache_administration_helper::get_definition_summaries();
$defaultmodestores = cache_administration_helper::get_default_mode_stores();
$locks = cache_administration_helper::get_lock_summaries();
@@ -67,7 +67,7 @@
$config['lock'] = $data->lock;
}
}
- $writer->add_plugin_instance($data->name, $data->plugin, $config);
+ $writer->add_store_instance($data->name, $data->plugin, $config);
redirect($PAGE->url, get_string('addstoresuccess', 'cache', $plugins[$plugin]['name']), 5);
}
break;
@@ -87,7 +87,7 @@
$config['lock'] = $data->lock;
}
}
- $writer->edit_plugin_instance($data->name, $data->plugin, $config);
+ $writer->edit_store_instance($data->name, $data->plugin, $config);
redirect($PAGE->url, get_string('editstoresuccess', 'cache', $plugins[$plugin]['name']), 5);
}
break;
@@ -120,7 +120,7 @@
exit;
} else {
$writer = cache_config_writer::instance();
- $writer->delete_store($store);
+ $writer->delete_store_instance($store);
redirect($PAGE->url, get_string('deletestoresuccess', 'cache'), 5);
}
}
@@ -186,8 +186,8 @@
if ($mform instanceof moodleform) {
$mform->display();
} else {
- echo $renderer->plugin_summaries($plugins);
- echo $renderer->store_summariers($stores, $plugins);
+ echo $renderer->store_plugin_summaries($plugins);
+ echo $renderer->store_instance_summariers($stores, $plugins);
echo $renderer->definition_summaries($definitions, cache_administration_helper::get_definition_actions($context));
echo $renderer->lock_summaries($locks);
View
2 cache/forms.php
@@ -93,7 +93,7 @@ public function validation($data, $files) {
if (!preg_match('#^[a-zA-Z0-9\-_ ]+$#', $data['name'])) {
$errors['name'] = get_string('storenameinvalid', 'cache');
} else if (empty($this->_customdata['store'])) {
- $stores = cache_administration_helper::get_store_summaries();
+ $stores = cache_administration_helper::get_store_instance_summaries();
if (array_key_exists($data['name'], $stores)) {
$errors['name'] = get_string('storenamealreadyused', 'cache');
}
View
20 cache/locallib.php
@@ -118,7 +118,7 @@ protected function config_save() {
* @return bool
* @throws cache_exception
*/
- public function add_plugin_instance($name, $plugin, array $configuration = array()) {
+ public function add_store_instance($name, $plugin, array $configuration = array()) {
if (array_key_exists($name, $this->configstores)) {
throw new cache_exception('Duplicate name specificed for cache plugin instance. You must provide a unique name.');
}
@@ -219,7 +219,7 @@ public function set_mode_mappings(array $modemappings) {
* @return bool
* @throws cache_exception
*/
- public function edit_plugin_instance($name, $plugin, $configuration) {
+ public function edit_store_instance($name, $plugin, $configuration) {
if (!array_key_exists($name, $this->configstores)) {
throw new cache_exception('The requested instance does not exist.');
}
@@ -265,7 +265,7 @@ public function edit_plugin_instance($name, $plugin, $configuration) {
* @return bool
* @throws cache_exception
*/
- public function delete_store($name) {
+ public function delete_store_instance($name) {
if (!array_key_exists($name, $this->configstores)) {
throw new cache_exception('The requested store does not exist.');
}
@@ -488,7 +488,7 @@ public function set_definition_mappings($definition, $mappings) {
* Returns an array containing all of the information about stores a renderer needs.
* @return array
*/
- public static function get_store_summaries() {
+ public static function get_store_instance_summaries() {
$return = array();
$default = array();
$instance = cache_config::instance();
@@ -544,7 +544,7 @@ public static function get_store_summaries() {
* Returns an array of information about plugins, everything a renderer needs.
* @return array
*/
- public static function get_plugin_summaries() {
+ public static function get_store_plugin_summaries() {
$return = array();
$plugins = get_plugin_list_with_file('cachestore', 'lib.php', true);
foreach ($plugins as $plugin => $path) {
@@ -669,7 +669,7 @@ public static function get_definition_actions(context $context) {
* @param array $storedetails
* @return array
*/
- public static function get_store_actions($name, array $storedetails) {
+ public static function get_store_instance_actions($name, array $storedetails) {
$actions = array();
if (has_capability('moodle/site:config', get_system_context())) {
$baseurl = new moodle_url('/cache/admin.php', array('store' => $name, 'sesskey' => sesskey()));
@@ -699,7 +699,7 @@ public static function get_store_actions($name, array $storedetails) {
* @param array $plugindetails
* @return array
*/
- public static function get_plugin_actions($name, array $plugindetails) {
+ public static function get_store_plugin_actions($name, array $plugindetails) {
$actions = array();
if (has_capability('moodle/site:config', get_system_context())) {
if (!empty($plugindetails['canaddinstance'])) {
@@ -738,7 +738,7 @@ public static function get_add_store_form($plugin) {
}
}
- $locks = self::get_possible_locks_for_plugin($plugindir, $plugin);
+ $locks = self::get_possible_locks_for_stores($plugindir, $plugin);
$url = new moodle_url('/cache/admin.php', array('action' => 'addstore'));
return new $class($url, array('plugin' => $plugin, 'store' => null, 'locks' => $locks));
@@ -776,7 +776,7 @@ public static function get_edit_store_form($plugin, $store) {
}
}
- $locks = self::get_possible_locks_for_plugin($plugindir, $plugin);
+ $locks = self::get_possible_locks_for_stores($plugindir, $plugin);
$url = new moodle_url('/cache/admin.php', array('action' => 'editstore'));
return new $class($url, array('plugin' => $plugin, 'store' => $store, 'locks' => $locks));
@@ -789,7 +789,7 @@ public static function get_edit_store_form($plugin, $store) {
* @param string $plugin
* @return array|false
*/
- protected static function get_possible_locks_for_plugin($plugindir, $plugin) {
+ protected static function get_possible_locks_for_stores($plugindir, $plugin) {
global $CFG; // Needed for includes.
$supportsnativelocking = false;
if (file_exists($plugindir.'/lib.php')) {
View
8 cache/renderer.php
@@ -44,7 +44,7 @@ class core_cache_renderer extends plugin_renderer_base {
* @param array $plugins
* @return string HTML
*/
- public function store_summariers(array $stores, array $plugins) {
+ public function store_instance_summariers(array $stores, array $plugins) {
$table = new html_table();
$table->head = array(
get_string('storename', 'cache'),
@@ -69,7 +69,7 @@ public function store_summariers(array $stores, array $plugins) {
$defaultstoreactions = get_string('defaultstoreactions', 'cache');
foreach ($stores as $name => $store) {
- $actions = cache_administration_helper::get_store_actions($name, $store);
+ $actions = cache_administration_helper::get_store_instance_actions($name, $store);
$modes = array();
foreach ($store['modes'] as $mode => $enabled) {
if ($enabled) {
@@ -127,7 +127,7 @@ public function store_summariers(array $stores, array $plugins) {
* @param array $plugins
* @return string HTML
*/
- public function plugin_summaries(array $plugins) {
+ public function store_plugin_summaries(array $plugins) {
$table = new html_table();
$table->head = array(
get_string('plugin', 'cache'),
@@ -148,7 +148,7 @@ public function plugin_summaries(array $plugins) {
$table->data = array();
foreach ($plugins as $name => $plugin) {
- $actions = cache_administration_helper::get_plugin_actions($name, $plugin);
+ $actions = cache_administration_helper::get_store_plugin_actions($name, $plugin);
$modes = array();
foreach ($plugin['modes'] as $mode => $enabled) {
View
32 cache/tests/locallib_test.php
@@ -165,26 +165,26 @@ public function test_add_edit_delete_plugin_instance() {
$this->assertArrayNotHasKey('addplugintest', $config->get_all_stores());
$this->assertArrayNotHasKey('addplugintestwlock', $config->get_all_stores());
// Add a default file instance.
- $config->add_plugin_instance('addplugintest', 'file');
+ $config->add_store_instance('addplugintest', 'file');
cache_factory::reset();
$config = cache_config_writer::instance();
$this->assertArrayHasKey('addplugintest', $config->get_all_stores());
// Add a store with a lock described.
- $config->add_plugin_instance('addplugintestwlock', 'file', array('lock' => 'default_file_lock'));
+ $config->add_store_instance('addplugintestwlock', 'file', array('lock' => 'default_file_lock'));
$this->assertArrayHasKey('addplugintestwlock', $config->get_all_stores());
- $config->delete_store('addplugintest');
+ $config->delete_store_instance('addplugintest');
$this->assertArrayNotHasKey('addplugintest', $config->get_all_stores());
$this->assertArrayHasKey('addplugintestwlock', $config->get_all_stores());
- $config->delete_store('addplugintestwlock');
+ $config->delete_store_instance('addplugintestwlock');
$this->assertArrayNotHasKey('addplugintest', $config->get_all_stores());
$this->assertArrayNotHasKey('addplugintestwlock', $config->get_all_stores());
// Add a default file instance.
- $config->add_plugin_instance('storeconfigtest', 'file', array('test' => 'a', 'one' => 'two'));
+ $config->add_store_instance('storeconfigtest', 'file', array('test' => 'a', 'one' => 'two'));
$stores = $config->get_all_stores();
$this->assertArrayHasKey('storeconfigtest', $stores);
$this->assertArrayHasKey('configuration', $stores['storeconfigtest']);
@@ -193,7 +193,7 @@ public function test_add_edit_delete_plugin_instance() {
$this->assertEquals('a', $stores['storeconfigtest']['configuration']['test']);
$this->assertEquals('two', $stores['storeconfigtest']['configuration']['one']);
- $config->edit_plugin_instance('storeconfigtest', 'file', array('test' => 'b', 'one' => 'three'));
+ $config->edit_store_instance('storeconfigtest', 'file', array('test' => 'b', 'one' => 'three'));
$stores = $config->get_all_stores();
$this->assertArrayHasKey('storeconfigtest', $stores);
$this->assertArrayHasKey('configuration', $stores['storeconfigtest']);
@@ -202,25 +202,25 @@ public function test_add_edit_delete_plugin_instance() {
$this->assertEquals('b', $stores['storeconfigtest']['configuration']['test']);
$this->assertEquals('three', $stores['storeconfigtest']['configuration']['one']);
- $config->delete_store('storeconfigtest');
+ $config->delete_store_instance('storeconfigtest');
try {
- $config->delete_store('default_application');
+ $config->delete_store_instance('default_application');
$this->fail('Default store deleted. This should not be possible!');
} catch (Exception $e) {
$this->assertInstanceOf('cache_exception', $e);
}
try {
- $config->delete_store('some_crazy_store');
+ $config->delete_store_instance('some_crazy_store');
$this->fail('You should not be able to delete a store that does not exist.');
} catch (Exception $e) {
$this->assertInstanceOf('cache_exception', $e);
}
try {
// Try with a plugin that does not exist.
- $config->add_plugin_instance('storeconfigtest', 'shallowfail', array('test' => 'a', 'one' => 'two'));
+ $config->add_store_instance('storeconfigtest', 'shallowfail', array('test' => 'a', 'one' => 'two'));
$this->fail('You should not be able to add an instance of a store that does not exist.');
} catch (Exception $e) {
$this->assertInstanceOf('cache_exception', $e);
@@ -232,7 +232,7 @@ public function test_add_edit_delete_plugin_instance() {
*/
public function test_set_mode_mappings() {
$config = cache_config_writer::instance();
- $this->assertTrue($config->add_plugin_instance('setmodetest', 'file'));
+ $this->assertTrue($config->add_store_instance('setmodetest', 'file'));
$this->assertTrue($config->set_mode_mappings(array(
cache_store::MODE_APPLICATION => array('setmodetest', 'default_application'),
cache_store::MODE_SESSION => array('default_session'),
@@ -260,7 +260,7 @@ public function test_set_definition_mappings() {
));
$config = cache_config_writer::instance();
- $this->assertTrue($config->add_plugin_instance('setdefinitiontest', 'file'));
+ $this->assertTrue($config->add_store_instance('setdefinitiontest', 'file'));
$this->assertInternalType('array', $config->get_definition_by_id('phpunit/testdefinition'));
$config->set_definition_mappings('phpunit/testdefinition', array('setdefinitiontest', 'default_application'));
@@ -303,15 +303,15 @@ public function setUp() {
public function test_get_summaries() {
// First the preparation.
$config = cache_config_writer::instance();
- $this->assertTrue($config->add_plugin_instance('summariesstore', 'file'));
+ $this->assertTrue($config->add_store_instance('summariesstore', 'file'));
$config->set_definition_mappings('core/eventinvalidation', array('summariesstore'));
$this->assertTrue($config->set_mode_mappings(array(
cache_store::MODE_APPLICATION => array('summariesstore'),
cache_store::MODE_SESSION => array('default_session'),
cache_store::MODE_REQUEST => array('default_request'),
)));
- $storesummaries = cache_administration_helper::get_store_summaries();
+ $storesummaries = cache_administration_helper::get_store_instance_summaries();
$this->assertInternalType('array', $storesummaries);
$this->assertArrayHasKey('summariesstore', $storesummaries);
$summary = $storesummaries['summariesstore'];
@@ -352,7 +352,7 @@ public function test_get_summaries() {
$this->assertInternalType('array', $summary['mappings']);
$this->assertContains('summariesstore', $summary['mappings']);
- $pluginsummaries = cache_administration_helper::get_plugin_summaries();
+ $pluginsummaries = cache_administration_helper::get_store_plugin_summaries();
$this->assertInternalType('array', $pluginsummaries);
$this->assertArrayHasKey('file', $pluginsummaries);
$summary = $pluginsummaries['file'];
@@ -403,7 +403,7 @@ public function test_get_add_store_form() {
*/
public function test_get_edit_store_form() {
$config = cache_config_writer::instance();
- $this->assertTrue($config->add_plugin_instance('summariesstore', 'file'));
+ $this->assertTrue($config->add_store_instance('summariesstore', 'file'));
$form = cache_administration_helper::get_edit_store_form('file', 'summariesstore');
$this->assertInstanceOf('moodleform', $form);
View
4 lang/en/cache.php
@@ -85,7 +85,7 @@
$string['nativelocking'] = 'This plugin handles its own locking.';
$string['none'] = 'None';
$string['plugin'] = 'Plugin';
-$string['pluginsummaries'] = 'Installed cache plugins';
+$string['pluginsummaries'] = 'Installed cache stores';
$string['purge'] = 'Purge';
$string['purgestoresuccess'] = 'Successfully purged the requested store.';
$string['requestcount'] = 'Test with {$a} requests';
@@ -106,7 +106,7 @@
$string['store_default_application'] = 'Default file store for application caches';
$string['store_default_request'] = 'Default static store for request caches';
$string['store_default_session'] = 'Default session store for session caches';
-$string['storesummaries'] = 'Configured plugin instances';
+$string['storesummaries'] = 'Configured store instances';
$string['supports'] = 'Supports';
$string['supports_multipleidentifiers'] = 'multiple identifiers';
$string['supports_dataguarantee'] = 'data guarantee';

0 comments on commit 26ce56f

Please sign in to comment.