/** * @param null $useChain * * @return Geocoder */ protected function instance($useChain = NULL) { if (!isset($this->_geocoder) or NULL !== $useChain) { // Initializing Geocoder $this->_geocoder = new \Geocoder\Geocoder(); if ($useChain && count($this->_providers) > 1) { $this->_geocoder->registerProvider(new \Geocoder\Provider\ChainProvider($this->_providers)); } else { $this->_geocoder->registerProviders($this->_providers); } } return $this->_geocoder; }
/** * Constructs a geocoder and builds providers from plugin settings */ function __construct() { if (!isset(self::$adapter)) { self::$adapter = new GuzzleHttpAdapter(); } if (!isset(self::$providers)) { self::$providers = array_filter(array($this->buildFreeGeoIpProvider())); } if (!count(self::$providers)) { elgg_add_admin_notice('geo:providers', elgg_echo('geo:providers:none')); } else { if (!isset(self::$geocoder)) { $geocoder = new Geocoder(); $geocoder->registerProviders(self::$providers); self::$geocoder = $geocoder; } } }
/** * Registers a set of providers. * * @param \Geocoder\ProviderInterface[] $providers * @return \Geocoder\GeocoderInterface * @static */ public static function registerProviders($providers = array()) { return \Geocoder\Geocoder::registerProviders($providers); }