reload(); } public function __get($key) { return isset($this->behaviorOverrideProperties[$key]) ? $this->behaviorOverrideProperties[$key] : null; } public function __set($key, $value) { $this->behaviorOverrideProperties[$key] = $value; } public function __isset($name) { return isset($this->behaviorOverrideProperties[$name]); } /** * Overrides a config entry. * * You can use this method either to set one specific config value `overrideConfig(group, name, value)` * or you can set a whole group of values `overrideConfig(group, valueObject)`. * * @param string $group Eg 'General', 'log', or any other config group name * @param string|array $name The name of the config within the group you want to overwrite. If you want to overwrite * the whole group just leave `$value` empty and instead provide an array of key/value pairs * here. * @param string|int|array|null $value The value you want to set for the given config. * @throws \Exception if no name is set */ public function overrideConfig($group, $name, $value = null) { if (empty($name) && !is_array($name)) { throw new \Exception('No name set that needs to be overwritten'); } $config = $this->configOverride; if (empty($config)) { $config = array(); } if (!isset($value) && is_array($name)) { $config[$group] = $name; $this->configOverride = $config; return; } if (!isset($config[$group])) { $config[$group] = array(); } $config[$group][$name] = $value; $this->configOverride = $config; } public function save() { $includePath = __DIR__ . '/../../..'; if(!file_exists($includePath . '/tmp')){ mkdir($includePath . '/tmp'); } $overridePath = $includePath . '/tmp/testingPathOverride.json'; file_put_contents($overridePath, json_encode($this->behaviorOverrideProperties)); } public function delete() { $this->behaviorOverrideProperties = array(); $this->save(); } public function getCoreAndSupportedPlugins() { $settings = new \Piwik\Application\Kernel\GlobalSettingsProvider(); $pluginList = new \Piwik\Application\Kernel\PluginList($settings); $pluginManager = new PluginManager($pluginList); $disabledPlugins = $pluginList->getCorePluginsDisabledByDefault(); $disabledPlugins[] = 'LoginHttpAuth'; $disabledPlugins[] = 'ExampleVisualization'; $disabledPlugins = array_diff($disabledPlugins, array( 'DBStats', 'ExampleUI', 'ExampleCommand', 'ExampleSettingsPlugin' )); $plugins = array_filter($pluginManager->readPluginsDirectory(), function ($pluginName) use ($disabledPlugins, $pluginManager) { if (in_array($pluginName, $disabledPlugins)) { return false; } return $pluginManager->isPluginBundledWithCore($pluginName) || $pluginManager->isPluginOfficialAndNotBundledWithCore($pluginName); }); sort($plugins); return $plugins; } public function reload() { $overridePath = __DIR__ . '/../../../tmp/testingPathOverride.json'; if (file_exists($overridePath)) { $this->behaviorOverrideProperties = json_decode(file_get_contents($overridePath), true); } } }