MDL-41492 cache: Added ability for alternate cache config

This commit is contained in:
Peter Burnett 2020-04-06 14:15:34 +10:00
parent 611399214b
commit 40e41c1997
14 changed files with 1277 additions and 895 deletions

47
cache/renderer.php vendored
View file

@ -41,9 +41,9 @@ class core_cache_renderer extends plugin_renderer_base {
* Displays store summaries.
*
* @param array $storeinstancesummaries information about each store instance,
* as returned by cache_administration_helper::get_store_instance_summaries().
* as returned by core_cache\administration_helper::get_store_instance_summaries().
* @param array $storepluginsummaries information about each store plugin as
* returned by cache_administration_helper::get_store_plugin_summaries().
* returned by core_cache\administration_helper::get_store_plugin_summaries().
* @return string HTML
*/
public function store_instance_summariers(array $storeinstancesummaries, array $storepluginsummaries) {
@ -73,7 +73,7 @@ class core_cache_renderer extends plugin_renderer_base {
$defaultstoreactions = get_string('defaultstoreactions', 'cache');
foreach ($storeinstancesummaries as $name => $storesummary) {
$actions = cache_administration_helper::get_store_instance_actions($name, $storesummary);
$htmlactions = cache_factory::get_administration_display_helper()->get_store_instance_actions($name, $storesummary);
$modes = array();
foreach ($storesummary['modes'] as $mode => $enabled) {
if ($enabled) {
@ -92,10 +92,6 @@ class core_cache_renderer extends plugin_renderer_base {
if (!empty($storesummary['default'])) {
$info = $this->output->pix_icon('i/info', $defaultstoreactions, '', array('class' => 'icon'));
}
$htmlactions = array();
foreach ($actions as $action) {
$htmlactions[] = $this->output->action_link($action['url'], $action['text']);
}
$isready = $storesummary['isready'] && $storesummary['requirementsmet'];
$readycell = new html_table_cell;
@ -145,7 +141,7 @@ class core_cache_renderer extends plugin_renderer_base {
* Displays plugin summaries.
*
* @param array $storepluginsummaries information about each store plugin as
* returned by cache_administration_helper::get_store_plugin_summaries().
* returned by core_cache\administration_helper::get_store_plugin_summaries().
* @return string HTML
*/
public function store_plugin_summaries(array $storepluginsummaries) {
@ -169,7 +165,7 @@ class core_cache_renderer extends plugin_renderer_base {
$table->data = array();
foreach ($storepluginsummaries as $name => $plugin) {
$actions = cache_administration_helper::get_store_plugin_actions($name, $plugin);
$htmlactions = cache_factory::get_administration_display_helper()->get_store_plugin_actions($name, $plugin);
$modes = array();
foreach ($plugin['modes'] as $mode => $enabled) {
@ -185,11 +181,6 @@ class core_cache_renderer extends plugin_renderer_base {
}
}
$htmlactions = array();
foreach ($actions as $action) {
$htmlactions[] = $this->output->action_link($action['url'], $action['text']);
}
$row = new html_table_row(array(
$plugin['name'],
($plugin['requirementsmet']) ? $this->output->pix_icon('i/valid', '1') : '',
@ -214,7 +205,7 @@ class core_cache_renderer extends plugin_renderer_base {
* Displays definition summaries.
*
* @param array $definitionsummaries information about each definition, as returned by
* cache_administration_helper::get_definition_summaries().
* core_cache\administration_helper::get_definition_summaries().
* @param context $context the system context.
*
* @return string HTML.
@ -247,12 +238,7 @@ class core_cache_renderer extends plugin_renderer_base {
$none = new lang_string('none', 'cache');
foreach ($definitionsummaries as $id => $definition) {
$actions = cache_administration_helper::get_definition_actions($context, $definition);
$htmlactions = array();
foreach ($actions as $action) {
$action['url']->param('definition', $id);
$htmlactions[] = $this->output->action_link($action['url'], $action['text']);
}
$htmlactions = cache_factory::get_administration_display_helper()->get_definition_actions($context, $definition);
if (!empty($definition['mappings'])) {
$mapping = join(', ', $definition['mappings']);
} else {
@ -379,13 +365,24 @@ class core_cache_renderer extends plugin_renderer_base {
));
}
$url = new moodle_url('/cache/admin.php', array('action' => 'newlockinstance', 'sesskey' => sesskey()));
$select = new single_select($url, 'lock', cache_administration_helper::get_addable_lock_options());
$select->label = get_string('addnewlockinstance', 'cache');
$html = html_writer::start_tag('div', array('id' => 'core-cache-lock-summary'));
$html .= $this->output->heading(get_string('locksummary', 'cache'), 3);
$html .= html_writer::table($table);
$html .= html_writer::end_tag('div');
return $html;
}
/**
* Renders additional actions for locks, such as Add.
*
* @return string
*/
public function additional_lock_actions() : string {
$url = new moodle_url('/cache/admin.php', array('action' => 'newlockinstance', 'sesskey' => sesskey()));
$select = new single_select($url, 'lock', cache_factory::get_administration_display_helper()->get_addable_lock_options());
$select->label = get_string('addnewlockinstance', 'cache');
$html = html_writer::start_tag('div', array('id' => 'core-cache-lock-additional-actions'));
$html .= html_writer::tag('div', $this->output->render($select), array('class' => 'new-instance'));
$html .= html_writer::end_tag('div');
return $html;