mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-40759 fontawesome: Use a cache
Cache the callback info.
This commit is contained in:
parent
2154c9824d
commit
7e8940b544
4 changed files with 26 additions and 8 deletions
|
@ -431,16 +431,23 @@ class icon_system_fontawesome extends icon_system_font {
|
|||
*/
|
||||
public function get_icon_name_map() {
|
||||
if ($this->map === []) {
|
||||
$this->map = $this->get_core_icon_map();
|
||||
$callback = 'get_fontawesome_icon_map';
|
||||
$cache = \cache::make('core', 'fontawesomeiconmapping');
|
||||
|
||||
if ($pluginsfunction = get_plugins_with_function($callback)) {
|
||||
foreach ($pluginsfunction as $plugintype => $plugins) {
|
||||
foreach ($plugins as $pluginfunction) {
|
||||
$pluginmap = $pluginfunction();
|
||||
$this->map += $pluginmap;
|
||||
$this->map = $cache->get('mapping');
|
||||
|
||||
if (empty($this->map)) {
|
||||
$this->map = $this->get_core_icon_map();
|
||||
$callback = 'get_fontawesome_icon_map';
|
||||
|
||||
if ($pluginsfunction = get_plugins_with_function($callback)) {
|
||||
foreach ($pluginsfunction as $plugintype => $plugins) {
|
||||
foreach ($plugins as $pluginfunction) {
|
||||
$pluginmap = $pluginfunction();
|
||||
$this->map += $pluginmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
$cache->set('mapping', $this->map);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue