本文整理汇总了PHP中Piwik\Common::getCurrentLocationProviderId方法的典型用法代码示例。如果您正苦于以下问题:PHP Common::getCurrentLocationProviderId方法的具体用法?PHP Common::getCurrentLocationProviderId怎么用?PHP Common::getCurrentLocationProviderId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Common
的用法示例。
在下文中一共展示了Common::getCurrentLocationProviderId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enrichVisitWithLocation
public function enrichVisitWithLocation(&$visitorInfo, \Piwik\Tracker\Request $request)
{
require_once PIWIK_INCLUDE_PATH . "/plugins/UserCountry/LocationProvider.php";
$ipAddress = IP::N2P(Config::getInstance()->Tracker['use_anonymized_ip_for_visit_enrichment'] == 1 ? $visitorInfo['location_ip'] : $request->getIp());
$userInfo = array('lang' => $visitorInfo['location_browser_lang'], 'ip' => $ipAddress);
$id = Common::getCurrentLocationProviderId();
$provider = LocationProvider::getProviderById($id);
if ($provider === false) {
$id = DefaultProvider::ID;
$provider = LocationProvider::getProviderById($id);
Common::printDebug("GEO: no current location provider sent, falling back to default '{$id}' one.");
}
$location = $provider->getLocation($userInfo);
// if we can't find a location, use default provider
if ($location === false) {
$defaultId = DefaultProvider::ID;
$provider = LocationProvider::getProviderById($defaultId);
$location = $provider->getLocation($userInfo);
Common::printDebug("GEO: couldn't find a location with Geo Module '{$id}', using Default '{$defaultId}' provider as fallback...");
$id = $defaultId;
}
Common::printDebug("GEO: Found IP {$ipAddress} location (provider '" . $id . "'): " . var_export($location, true));
if (empty($location['country_code'])) {
// sanity check
$location['country_code'] = \Piwik\Tracker\Visit::UNKNOWN_CODE;
}
// add optional location components
$this->updateVisitInfoWithLocation($visitorInfo, $location);
}
示例2: __construct
public function __construct(LocationProvider $provider = null, LocationProvider $backupProvider = null, Cache $locationCache = null, RawLogDao $dao = null, LoggerInterface $logger = null)
{
if ($provider === null) {
// note: Common::getCurrentLocationProviderId() uses the tracker cache, which is why it's used here instead
// of accessing the option table
$provider = LocationProvider::getProviderById(Common::getCurrentLocationProviderId());
if (empty($provider)) {
Common::printDebug("GEO: no current location provider sent, falling back to default '" . DefaultProvider::ID . "' one.");
$provider = $this->getDefaultProvider();
}
}
$this->provider = $provider;
$this->backupProvider = $backupProvider ?: $this->getDefaultProvider();
$this->locationCache = $locationCache ?: self::getDefaultLocationCache();
$this->dao = $dao ?: new RawLogDao();
$this->logger = $logger ?: StaticContainer::get('Psr\\Log\\LoggerInterface');
}
示例3: getProvider
private function getProvider()
{
$id = Common::getCurrentLocationProviderId();
$provider = LocationProvider::getProviderById($id);
if ($provider === false) {
$provider = $this->getDefaultProvider();
Common::printDebug("GEO: no current location provider sent, falling back to default '{$id}' one.");
}
return $provider;
}