Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-07-02 10:13:04 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-07-02 10:13:04 +0400
commit286b05c4d5d2cac010b0cd429763112ee7dc61c4 (patch)
tree6e8bda59d5bfe28606ac1d7669d455b110659a12 /core/WidgetsList.php
parent535cb4b0028b6eff460b1ad68086c604e5320425 (diff)
Widgetslist::get is called 14 times, cache the list of widgets to prevent from sorting and translating all keys 14 times by caching
Diffstat (limited to 'core/WidgetsList.php')
-rw-r--r--core/WidgetsList.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/core/WidgetsList.php b/core/WidgetsList.php
index 531d802405..be41740ed8 100644
--- a/core/WidgetsList.php
+++ b/core/WidgetsList.php
@@ -8,6 +8,7 @@
*/
namespace Piwik;
+use Piwik\Cache\PluginAwareStaticCache;
use Piwik\Plugin\Report;
use Piwik\Plugin\Widgets;
@@ -55,6 +56,11 @@ class WidgetsList extends Singleton
*/
static public function get()
{
+ $cache = new PluginAwareStaticCache('WidgetsList');
+ if ($cache->has()) {
+ return $cache->get();
+ }
+
self::addWidgets();
uksort(self::$widgets, array('Piwik\WidgetsList', '_sortWidgetCategories'));
@@ -70,6 +76,8 @@ class WidgetsList extends Singleton
$widgets[$category] = $v;
}
+ $cache->set($widgets);
+
return $widgets;
}