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:
authordiosmosis <benakamoorthi@fastmail.fm>2014-06-16 02:40:05 +0400
committerdiosmosis <benakamoorthi@fastmail.fm>2014-06-16 02:40:30 +0400
commitb7c3f39647a2c3cbb83465d42f84d9e7636f3f18 (patch)
treee2af3e93994ec190bed85d9e0a5dac924a85567b /core/Plugin.php
parent4e17f95f2edf06ddf532d5e212c5eeca11efd80b (diff)
When executing tests, check for non-core plugin that should be loaded by looking at test case class & current backtrace. (Removing need for enable_load_standalone_plugins_during_tests config option).
Diffstat (limited to 'core/Plugin.php')
-rw-r--r--core/Plugin.php27
1 files changed, 22 insertions, 5 deletions
diff --git a/core/Plugin.php b/core/Plugin.php
index aeb687398e..2ddd07aa26 100644
--- a/core/Plugin.php
+++ b/core/Plugin.php
@@ -353,12 +353,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;
+ }
+ }
+} \ No newline at end of file