Piwik\Plugins\UserCountry\LocationProvider\GeoIp::getPathToGeoIpDatabase PHP Метод

getPathToGeoIpDatabase() публичный статический Метод

Returns the path of an existing GeoIP database or false if none can be found.
public static getPathToGeoIpDatabase ( array $possibleFileNames ) : string | false
$possibleFileNames array The list of possible file names for the GeoIP database.
Результат string | false
    public static function getPathToGeoIpDatabase($possibleFileNames)
    {
        foreach ($possibleFileNames as $filename) {
            $path = self::getPathForGeoIpDatabase($filename);
            if (file_exists($path)) {
                return $path;
            }
        }
        return false;
    }

Usage Example

Пример #1
0
 private function setLocationProvider($file)
 {
     GeoIp::$dbNames['loc'] = array($file);
     GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
     LocationProvider::$providers = null;
     LocationProvider::setCurrentProvider(self::GEOIP_IMPL_TO_TEST);
     if (LocationProvider::getCurrentProviderId() !== self::GEOIP_IMPL_TO_TEST) {
         throw new Exception("Failed to set the current location provider to '" . self::GEOIP_IMPL_TO_TEST . "'.");
     }
     $possibleFiles = GeoIp::$dbNames['loc'];
     if (GeoIp::getPathToGeoIpDatabase($possibleFiles) === false) {
         throw new Exception("The GeoIP location provider cannot find the '{$file}' file! Tests will fail.");
     }
 }
All Usage Examples Of Piwik\Plugins\UserCountry\LocationProvider\GeoIp::getPathToGeoIpDatabase