本文整理汇总了PHP中Piwik\Config::setSingletonInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::setSingletonInstance方法的具体用法?PHP Config::setSingletonInstance怎么用?PHP Config::setSingletonInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Config
的用法示例。
在下文中一共展示了Config::setSingletonInstance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addHooks
public static function addHooks()
{
$testingEnvironment = new Piwik_TestingEnvironment();
if ($testingEnvironment->queryParamOverride) {
foreach ($testingEnvironment->queryParamOverride as $key => $value) {
$_GET[$key] = $value;
}
}
if ($testingEnvironment->globalsOverride) {
foreach ($testingEnvironment->globalsOverride as $key => $value) {
$GLOBALS[$key] = $value;
}
}
Config::setSingletonInstance(new Config($testingEnvironment->configFileGlobal, $testingEnvironment->configFileLocal, $testingEnvironment->configFileCommon));
\Piwik\CacheFile::$invalidateOpCacheBeforeRead = true;
Piwik::addAction('Access.createAccessSingleton', function ($access) use($testingEnvironment) {
if (!$testingEnvironment->testUseRegularAuth) {
$access = new Piwik_MockAccess($access);
\Piwik\Access::setSingletonInstance($access);
}
});
if (!$testingEnvironment->dontUseTestConfig) {
Piwik::addAction('Config.createConfigSingleton', function (Config $config, &$cache, $local) use($testingEnvironment) {
$config->setTestEnvironment($testingEnvironment->configFileLocal, $testingEnvironment->configFileGlobal, $testingEnvironment->configFileCommon);
if ($testingEnvironment->configFileLocal) {
unset($cache['General']);
$config->General['session_save_handler'] = 'dbtable';
}
$manager = \Piwik\Plugin\Manager::getInstance();
$pluginsToLoad = $manager->getPluginsToLoadDuringTests();
$config->Plugins = array('Plugins' => $pluginsToLoad);
$trackerPluginsToLoad = array_filter($pluginsToLoad, function ($plugin) use($manager) {
return $manager->isTrackerPlugin($manager->loadPlugin($plugin));
});
$config->Plugins_Tracker = array('Plugins_Tracker' => $trackerPluginsToLoad);
$log = $config->log;
$log['log_writers'] = array('file');
$config->log = $log;
$manager->unloadPlugins();
// TODO: replace this and below w/ configOverride use
if ($testingEnvironment->tablesPrefix) {
$cache['database']['tables_prefix'] = $testingEnvironment->tablesPrefix;
}
if ($testingEnvironment->dbName) {
$cache['database']['dbname'] = $testingEnvironment->dbName;
}
if ($testingEnvironment->configOverride) {
$cache = $testingEnvironment->arrayMergeRecursiveDistinct($cache, $testingEnvironment->configOverride);
}
});
}
Piwik::addAction('Request.dispatch', function () {
\Piwik\Plugins\CoreVisualizations\Visualizations\Cloud::$debugDisableShuffle = true;
\Piwik\Visualization\Sparkline::$enableSparklineImages = false;
\Piwik\Plugins\ExampleUI\API::$disableRandomness = true;
});
Piwik::addAction('AssetManager.getStylesheetFiles', function (&$stylesheets) {
$stylesheets[] = 'tests/resources/screenshot-override/override.css';
});
Piwik::addAction('AssetManager.getJavaScriptFiles', function (&$jsFiles) {
$jsFiles[] = 'tests/resources/screenshot-override/override.js';
});
self::addSendMailHook();
Piwik::addAction('Updater.checkForUpdates', function () {
try {
@\Piwik\Filesystem::deleteAllCacheOnUpdate();
} catch (Exception $ex) {
// pass
}
});
$testingEnvironment->logVariables();
$testingEnvironment->executeSetupTestEnvHook();
}