diff options
Diffstat (limited to 'core/Plugin.php')
-rw-r--r-- | core/Plugin.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/core/Plugin.php b/core/Plugin.php index 5f0c809896..a14cade95b 100644 --- a/core/Plugin.php +++ b/core/Plugin.php @@ -193,4 +193,23 @@ class Plugin { return $this->pluginName; } -} + + /** + * Extracts the plugin name from a backtrace array. Returns false if we can't find one. + * + * @param array $backtrace The result of the debug_backtrace() or Exception::getTrace(). + * @return string|false + */ + public static function getPluginNameFromBacktrace($backtrace) + { + 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]; + } + } + return false; + } +}
\ No newline at end of file |