当前位置: 首页>>代码示例>>PHP>>正文


PHP Common::getCurrentLocationProviderId方法代码示例

本文整理汇总了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);
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:29,代码来源:UserCountry.php

示例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');
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:17,代码来源:VisitorGeolocator.php

示例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;
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:10,代码来源:Base.php


注:本文中的Piwik\Common::getCurrentLocationProviderId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。