diff options
Diffstat (limited to 'core/Metrics.php')
-rw-r--r-- | core/Metrics.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/core/Metrics.php b/core/Metrics.php index 9ee9a16ce1..144e0ec291 100644 --- a/core/Metrics.php +++ b/core/Metrics.php @@ -9,6 +9,8 @@ namespace Piwik; use Piwik\Cache as PiwikCache; +use Piwik\Columns\MetricsList; +use Piwik\Container\StaticContainer; require_once PIWIK_INCLUDE_PATH . "/core/Piwik.php"; @@ -175,6 +177,36 @@ class Metrics Metrics::INDEX_NB_VISITS_CONVERTED, ); + public static function getMappingFromIdToName() + { + $cache = StaticContainer::get(PiwikCache\Transient::class); + $cacheKey = CacheId::siteAware(CacheId::pluginAware('Metrics.mappingFromIdToName')); + + $value = $cache->fetch($cacheKey); + if (empty($value)) { + $value = self::$mappingFromIdToName; + + /** + * Use this event if your plugin uses custom metric integer IDs to associate those IDs with the + * actual metric names (eg, 2 => nb_visits). This allows matomo to automate the replacing + * of IDs => metric names for your new metrics. + * + * **Example** + * + * public function addMetricIdToNameMapping(&$mapping) + * { + * $mapping[Archiver::INDEX_MY_NEW_METRIC] = $mapping['MyPlugin_myNewMetric']; + * } + * + * @ignore + */ + Piwik::postEvent('Metrics.addMetricIdToNameMapping', [&$value]); + + $cache->save($cacheKey, $value); + } + return $value; + } + public static function getVisitsMetricNames() { $names = array(); |