本文整理汇总了PHP中Piwik\SettingsServer::setIsNotTrackerApiRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP SettingsServer::setIsNotTrackerApiRequest方法的具体用法?PHP SettingsServer::setIsNotTrackerApiRequest怎么用?PHP SettingsServer::setIsNotTrackerApiRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\SettingsServer
的用法示例。
在下文中一共展示了SettingsServer::setIsNotTrackerApiRequest方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeTrackerInstance
private function makeTrackerInstance()
{
SettingsServer::setIsTrackerApiRequest();
$storage = Factory::make('PluginName');
SettingsServer::setIsNotTrackerApiRequest();
return $storage;
}
示例2: sendRequest
protected function sendRequest($url, $method = 'GET', $data = null, $force = false)
{
if ($this->DEBUG_APPEND_URL) {
$url .= $this->DEBUG_APPEND_URL;
}
// if doing a bulk request, store the url
if ($this->doBulkRequests && !$force) {
$this->storedTrackingActions[] = $url;
return true;
}
if ($method == 'POST') {
$requests = array();
foreach ($this->storedTrackingActions as $action) {
$requests[] = $this->parseUrl($action);
}
$testEnvironmentArgs = array();
} else {
$testEnvironmentArgs = $this->parseUrl($url);
$requests = array($testEnvironmentArgs);
}
// unset cached values
Cache::$cache = null;
Tracker\Visit::$dimensions = null;
// save some values
$plugins = Config::getInstance()->Plugins['Plugins'];
$oldTrackerConfig = Config::getInstance()->Tracker;
\Piwik\Plugin\Manager::getInstance()->unloadPlugins();
// modify config
\Piwik\SettingsServer::setIsTrackerApiRequest();
$GLOBALS['PIWIK_TRACKER_LOCAL_TRACKING'] = true;
Tracker::$initTrackerMode = false;
Tracker::setTestEnvironment($testEnvironmentArgs, $method);
// set language
$oldLang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '';
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = $this->acceptLanguage;
// set user agent
$oldUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$_SERVER['HTTP_USER_AGENT'] = $this->userAgent;
// set cookie
$oldCookie = $_COOKIE;
// parse_str(parse_url($this->requestCookie, PHP_URL_QUERY), $_COOKIE);
// do tracking and capture output
ob_start();
$localTracker = new Tracker();
$request = new Tracker\RequestSet();
$request->setRequests($requests);
\Piwik\Plugin\Manager::getInstance()->loadTrackerPlugins();
$handler = Tracker\Handler\Factory::make();
$response = $localTracker->main($handler, $request);
if (!is_null($response)) {
echo $response;
}
$output = ob_get_contents();
ob_end_clean();
// restore vars
Config::getInstance()->Tracker = $oldTrackerConfig;
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = $oldLang;
$_SERVER['HTTP_USER_AGENT'] = $oldUserAgent;
$_COOKIE = $oldCookie;
$GLOBALS['PIWIK_TRACKER_LOCAL_TRACKING'] = false;
\Piwik\SettingsServer::setIsNotTrackerApiRequest();
unset($_GET['bots']);
// reload plugins
\Piwik\Plugin\Manager::getInstance()->loadPlugins($plugins);
return $output;
}
示例3: test_addSetting_shouldPassTrackerStorage_IfInTrackerMode
public function test_addSetting_shouldPassTrackerStorage_IfInTrackerMode()
{
$this->setSuperUser();
SettingsServer::setIsTrackerApiRequest();
$settings = $this->createSettingsInstance();
$setting = $this->buildUserSetting('myname', 'mytitle', 'myRandomName');
$settings->addSetting($setting);
SettingsServer::setIsNotTrackerApiRequest();
$storage = $setting->getStorage();
$this->assertTrue($storage instanceof SettingsStorage);
}