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@gmail.com>2015-01-06 05:14:43 +0300
committerThomas Steur <thomas.steur@gmail.com>2015-01-07 06:35:36 +0300
commit8f65202d38e55174a22060e760af608939b0d81f (patch)
tree745a32089fd79e7e8716bf6717d36231249b23f6 /core/Plugin/Report.php
parente4f3ea2279fd82802cb7e14f3299950d8ebd0a28 (diff)
by fixing the factory it looks like I can remove some hacks
Diffstat (limited to 'core/Plugin/Report.php')
-rw-r--r--core/Plugin/Report.php34
1 files changed, 33 insertions, 1 deletions
diff --git a/core/Plugin/Report.php b/core/Plugin/Report.php
index 36be7630a6..aaa95bee50 100644
--- a/core/Plugin/Report.php
+++ b/core/Plugin/Report.php
@@ -10,6 +10,7 @@ namespace Piwik\Plugin;
use Piwik\API\Proxy;
use Piwik\API\Request;
+use Piwik\Cache;
use Piwik\CacheId;
use Piwik\Columns\Dimension;
use Piwik\DataTable;
@@ -723,7 +724,38 @@ class Report
*/
public static function factory($module, $action)
{
- return ComponentFactory::factory($module, ucfirst($action), __CLASS__);
+ $listApiToReport = self::getMapOfModuleActionsToReport();
+ $api = $module . '.' . $action;
+
+ if (!array_key_exists($api, $listApiToReport)) {
+ return null;
+ }
+
+ $klassName = $listApiToReport[$api];
+
+ return new $klassName;
+ }
+
+ private static function getMapOfModuleActionsToReport()
+ {
+ $cacheId = 'ReportFactoryMap';
+
+ $cache = Cache::getEagerCache();
+ if ($cache->contains($cacheId)) {
+ $mapApiToReport = $cache->fetch($cacheId);
+ } else {
+ $reports = self::getAllReports();
+
+ $mapApiToReport = array();
+ foreach ($reports as $report) {
+ $key = $report->getModule() . '.' . $report->getAction();
+ $mapApiToReport[$key] = get_class($report);
+ }
+
+ $cache->save($cacheId, $mapApiToReport);
+ }
+
+ return $mapApiToReport;
}
/**