src/FilterSetting/Perimetersearch.php
protected function lookupGeo($address, $country)
    {
        // Trim the data. Better!
        $address = \trim($address);
        $country = \trim($country);

        // First check cache.
        $cacheResult = $this->getFromCache($address, $country);
        if (null !== $cacheResult) {
            return $cacheResult;
        }

        // If there is no data from the cache ask google.
        $lookupServices = (array) StringUtil::deserialize($this->get('lookupservice'), true);
        if (!\count($lookupServices)) {
            return null;
        }

        foreach ($lookupServices as $lookupService) {
            try {
                $callback = $this->getObjectFromName($lookupService['lookupservice']);

                // Call the main function.
                if (null !== $callback) {
                    /** @var Container $result */
                    $result = $callback
                        ->getCoordinates(
                            null,
                            null,
                            null,
                            $country,
                            $address,
                            $lookupService['apiToken'] ?: null
                        );

                    // Check if we have a result.
                    if (!$result->hasError()) {
                        $this->addToCache($address, $country, $result);

                        return $result;
                    }
                }
            } catch (\RuntimeException $exc) {
                // Okay, we have an error try next one.
                continue;
            }
        }

        // When we reach this point, we have no result, so return false.
        return null;
    }
protected function lookupGeo($address, $country)
    {
        // Trim the data. Better!
        $address = \trim($address);
        $country = \trim($country);

        // First check cache.
        $cacheResult = $this->getFromCache($address, $country);
        if (null !== $cacheResult) {
            return $cacheResult;
        }

        // If there is no data from the cache ask google.
        $lookupServices = (array) StringUtil::deserialize($this->get('lookupservice'), true);
        if (!\count($lookupServices)) {
            return null;
        }

        foreach ($lookupServices as $lookupService) {
            try {
                $callback = $this->getObjectFromName($lookupService['lookupservice']);

                // Call the main function.
                if (null !== $callback) {
                    /** @var Container $result */
                    $result = $callback
                        ->getCoordinates(
                            null,
                            null,
                            null,
                            $country,
                            $address,
                            $lookupService['apiToken'] ?: null
                        );

                    // Check if we have a result.
                    if (!$result->hasError()) {
                        $this->addToCache($address, $country, $result);

                        return $result;
                    }
                }
            } catch (\RuntimeException $exc) {
                // Okay, we have an error try next one.
                continue;
            }
        }

        // When we reach this point, we have no result, so return false.
        return null;
    }
protected function lookupGeo ( $ address , $ country ) { // Trim the data. Better! $ address = \ trim ( $ address ) ; $ country = \ trim ( $ country ) ; // First check cache. $ cacheResult = $ this -> getFromCache ( $ address , $ country ) ; if ( null !== $ cacheResult ) { return $ cacheResult ; } // If there is no data from the cache ask google. $ lookupServices = ( array ) StringUtil :: deserialize ( $ this -> get ( 'lookupservice' ) , true ) ; if ( ! \ count ( $ lookupServices ) ) { return null ; } foreach ( $ lookupServices as $ lookupService ) { try { $ callback = $ this -> getObjectFromName ( $ lookupService [ 'lookupservice' ] ) ; // Call the main function. if ( null !== $ callback ) { /** @var Container $result */ $ result = $ callback -> getCoordinates ( null , null , null , $ country , $ address , $ lookupService [ 'apiToken' ] ? : null ) ; // Check if we have a result. if ( ! $ result -> hasError ( ) ) { $ this -> addToCache ( $ address , $ country , $ result ) ; return $ result ; } } } catch ( \ RuntimeException $ exc ) { // Okay, we have an error try next one. continue ; } } // When we reach this point, we have no result, so return false. return null ; }
User the provider classes to make a look up.

@param string $address The full address to search for.
@param string $country The country as 2-letters form.

@return Container|null Return the container with all information or null on error.
User the provider classes to make a look up .