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:
Diffstat (limited to 'core/Plugin.php')
-rw-r--r--core/Plugin.php25
1 files changed, 21 insertions, 4 deletions
diff --git a/core/Plugin.php b/core/Plugin.php
index e9cbe2feae..967d23b0ec 100644
--- a/core/Plugin.php
+++ b/core/Plugin.php
@@ -383,12 +383,29 @@ class Plugin
{
foreach ($backtrace as $tracepoint) {
// try and discern the plugin name
- if (isset($tracepoint['class'])
- && preg_match("/Piwik\\\\Plugins\\\\([a-zA-Z_0-9]+)\\\\/", $tracepoint['class'], $matches)
- ) {
- return $matches[1];
+ if (isset($tracepoint['class'])) {
+ $className = self::getPluginNameFromNamespace($tracepoint['class']);
+ if ($className) {
+ return $className;
+ }
}
}
return false;
}
+
+ /**
+ * Extracts the plugin name from a namespace name or a fully qualified class name. Returns `false`
+ * if we can't find one.
+ *
+ * @param string $namespaceOrClassName The namespace or class string.
+ * @return string|false
+ */
+ public static function getPluginNameFromNamespace($namespaceOrClassName)
+ {
+ if (preg_match("/Piwik\\\\Plugins\\\\([a-zA-Z_0-9]+)\\\\/", $namespaceOrClassName, $matches)) {
+ return $matches[1];
+ } else {
+ return false;
+ }
+ }
}