geocoder-php / bazingageocoderbundle Goto Github PK
View Code? Open in Web Editor NEWIntegration of the Geocoder library into Symfony.
License: MIT License
Integration of the Geocoder library into Symfony.
License: MIT License
It would be wonderful, if the geocoder library has a logging provider/adapter.
So we can display some useful information in the webprofiler.
The question is, what information we can collect and which information are needed?
Here some suggestions:
@willdurand What do you think?
Hello!
Is there anybody that had encoding problems with this bundle?
For example:
object(Geocoder\Result\Geocoded)[623]
protected 'latitude' => float -27.5833
protected 'longitude' => float -48.5667
protected 'bounds' => null
protected 'streetNumber' => null
protected 'streetName' => null
protected 'cityDistrict' => null
protected 'city' => string 'Florian?polis' (length=13)
protected 'zipcode' => null
protected 'county' => null
protected 'countyCode' => null
protected 'region' => null
protected 'regionCode' => string '26' (length=2)
protected 'country' => string 'Brazil' (length=6)
protected 'countryCode' => string 'BR' (length=2)
protected 'timezone' => null
City with an accent is being returning with a ?
My page has <meta charset="utf-8" />
setted.
Thanks.
composer install
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
Unrecognized option "default_provider" under "bazinga_geocoder"
config.yml
:
bazinga_geocoder:
default_provider: google_maps
providers:
google_maps:
locale: ~
region: ~
use_ssl: true
free_geo_ip: ~
geo_plugin: ~
composer.json
:
"willdurand/geocoder-bundle": "3.1.*@dev",
This is a very recent error ...
I'm getting this error when trying to use this with Symfony v2.1.0:
Fatal error: Call to undefined method Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition::ifTrue() in Symfony/vendor/willdurand/geocoder-bundle/Bazinga/Bundle/GeocoderBundle/DependencyInjection/Configuration.php on line 65
PHP Fatal error: Call to undefined method Symfony\Component\Config\Definition\Builder\ScalarNodeDefinition::ifTrue() in Symfony/vendor/willdurand/geocoder-bundle/Bazinga/Bundle/GeocoderBundle/DependencyInjection/Configuration.php on line 65
How can we persist Geocoded object / result ?
Hi, i'm using GeocoderBundle, which is great.
I would like to use cache, but the documentation seems outdated on this part :
// config.yml cache: provider: openstreetmaps cache: some_service_id lifetime: 86400 locale: %locale%
Any chance that someone explain me how to configure cache ?
Following the documentation for the cache
bazinga_geocoder:
providers:
cache:
adapter: acme_cache_adapter
provider: google_maps
google_maps: ~
And following the flow of the BazingaGeocoderExtension and the AddProvidersPass the cache (or chain provider) will always be registered at the end so they will be completly useless.
The should probably be registered first (cache than chain) or all the adapters should be registered in the order present in the file so the user have complete control over it (probably what was suppose to be the purpose of the chain adapter...)
If the bug is real I could fix it if you want.
Hello.
I'm trying to understand this bundle, I would like to know at least the city from the users by IP address.
What I did:
bazinga_geocoder:
providers:
google_maps: ~
fake_ip: 150.162.121.63
$result = $this->container
->get('bazinga_geocoder.geocoder')
->geocode($request->server->get('REMOTE_ADDR'));
It returns:
The GoogleMapsProvider does not support IP addresses.
What I'm doing wrong? What is the best provider for this propose?
I've checked the ip address over maxmind page and it is returning the right city.
Thanks!
I just installed this and I started the motions of setting up the geocoder when I realized that there are annotations and a listener. Do you have any instructions on how to use these?
Yandex has moved to https. This issue has been fixed in "willdurand/geocoder": "3.1"
But this bundle requires ~3.0. To semi-solve the problem, I should add "willdurand/geocoder": "3.2", into composer.
Suggest to change requires to "willdurand/geocoder": "3.2",
I upgraded to the latest release and I get the following error message:
Attempted to call method \getLatitude\ on class \Geocoder\Model\AddressCollection\."
// Geocode pickup address
$result = $this->container->get('bazinga_geocoder.geocoder')
->using('google_maps')
->geocode(
$newParcel->pickup->address // street address info
);
var_dump($result->getLatitude());
I'm using the same getLatitude() like in your documentation, but yet i get this error.
When I output the result object, I get the following, so the info is there but the function getLatitude is missing it seems?
object(Geocoder\Model\AddressCollection)#658 (1) {
["addresses": "Geocoder\Model\AddressCollection": private] =>
array(1) {
[0] =>
object(Geocoder\Model\Address)#653 (10) {
["coordinates": "Geocoder\Model\Address": private] =>
object(Geocoder\Model\Coordinates)#654 (2) {
["latitude": "Geocoder\Model\Coordinates": private] =>
float(50.7896677)
["longitude": "Geocoder\Model\Coordinates": private] =>
float(5.4102027)
}
["bounds": "Geocoder\Model\Address": private] =>
object(Geocoder\Model\Bounds)#655 (4) {
["south": "Geocoder\Model\Bounds": private] =>
float(50.7896624)
["west": "Geocoder\Model\Bounds": private] =>
float(5.4101859)
["north": "Geocoder\Model\Bounds": private] =>
float(50.7896677)
["east": "Geocoder\Model\Bounds": private] =>
float(5.4102027)
}
["streetNumber": "Geocoder\Model\Address": private] =>
string(3) "101"
["streetName": "Geocoder\Model\Address": private] =>
string(9) "Tomstraat"
["subLocality": "Geocoder\Model\Address": private] =>
NULL
["locality": "Geocoder\Model\Address": private] =>
string(8) "Tongeren"
["postalCode": "Geocoder\Model\Address": private] =>
string(4) "3700"
["adminLevels": "Geocoder\Model\Address": private] =>
object(Geocoder\Model\AdminLevelCollection)#656 (1) {
["adminLevels": "Geocoder\Model\AdminLevelCollection": private] =>
array(2) {
[1] =>
object(Geocoder\Model\AdminLevel)#652 (3) {
["level": "Geocoder\Model\AdminLevel": private] =>
int(1)
["name": "Geocoder\Model\AdminLevel": private] =>
string(10) "Vlaanderen"
["code": "Geocoder\Model\AdminLevel": private] =>
string(10) "Vlaanderen"
}
[2] =>
object(Geocoder\Model\AdminLevel)#651 (3) {
["level": "Geocoder\Model\AdminLevel": private] =>
int(2)
["name": "Geocoder\Model\AdminLevel": private] =>
string(7) "Limburg"
["code": "Geocoder\Model\AdminLevel": private] =>
string(2) "LI"
}
}
}
["country": "Geocoder\Model\Address": private] =>
object(Geocoder\Model\Country)#657 (2) {
["name": "Geocoder\Model\Country": private] =>
string(7) "Belgium"
["code": "Geocoder\Model\Country": private] =>
string(2) "BE"
}
["timezone": "Geocoder\Model\Address": private] =>
NULL
}
}
}
Am I doing something wrong? or is this a bug?
Since few days, the repository of geocoder changed from https://github.com/geocoder-php/Geocoder to https://github.com/geocoder-php/php-common
In BazingaGeocoderBundle, the require is willdurand/geocoder: ~3.1
In geocoder-php/php-common
on version 3.3.1 "egeloen/http-adapter": "~0.8",
has been removed from the required packages. (It's still here in 3.3.0)
And geocoder-bundle is still using "CurlHttpAdapter" from namespace "Ivory\HttpAdapter" as bazinga_geocoder.geocoder.default_adapter.class
in https://github.com/geocoder-php/BazingaGeocoderBundle/blob/master/Resources/config/services.xml
I just installed the Bundle into my Symfony v3 project and set up the configuration in config.yml
bazinga_geocoder:
default_provider: google_maps
providers:
google_maps:
locale: de_DE
region: de_DE
api_key: xxxxxx
i try to gecode a location:
$geocode = $this->container->get('bazinga_geocoder.geocoder')->geocode($locationString);
i get this error:
Requests to this API must be over SSL. Load the API with "https://" instead of "http://"
I do not known how to set the ssl-connection - and i can't find it in the documentation.
After standard installation I was trying to execute following code:
$result = $this->container->get('bazinga_geocoder.geocoder')
->geocode($this->container->get('request')->server->get('REMOTE_ADDR'));
$body = $this->container->get('bazinga_geocoder.dumper_manager')
->get('geojson')
->dump($result);
and the result was:
Fatal error: Class 'Geocoder\Dumper\WkpDumper' not found
Geocoder documentation says that there is Well-Known Binary (WKB) dumper. There is no information about WkpDumper.
Changing geocoder-bundle/Bazinga/Bundle/GeocoderBundle/Resources/config/services.xml
from
<parameter key="bazinga_geocoder.dumper.wkp.class">Geocoder\Dumper\WkpDumper</parameter>
to
<parameter key="bazinga_geocoder.dumper.wkp.class">Geocoder\Dumper\WkbDumper</parameter>
fixes the problem.
I think change should be made across whole repository.
I'm not shure if it's a typo or delibarate action.
MapQuest Open Geocoding now requires an API key : http://open.mapquestapi.com/geocoding/
In the MapQuestProvider, the key is missing :
const REVERSE_ENDPOINT_URL = 'http://open.mapquestapi.com/geocoding/v1/reverse?lat=%F&lng=%F';
See release 2.3.0 of Geocoder.
Hi,
I got the following config for the geocoder:
bazinga_geocoder:
adapter: app.http_adapter_guzzle.geocoder
providers:
openstreetmap:
locale: "%locale%"
google_maps:
locale: "%locale%"
bing_maps:
api_key: "%api.bing_maps.key%"
locale: "%locale%"
chain:
providers:
- openstreetmap
- google_maps
- bing_maps
Trying php7, somehow the bundle wants to "force load" geoip (the pecl module is not compatible with php7).
Somehow the AddProviderPass also finds geoip (as shown by xdebug) , but it's not enabled / configured on my side:
Any clue?
Hi,
The bundle is now compatible with Geocoder 2.3 and upper. It means that we should refactor the result factories to the bundle. In this way, we need to adapt the command, the logger and providers as we can get mutilple results now.
For the providers, it's not a problem but how do you think we should implement the command and the logger ?
Is it planned to make it compatible this Bundle with Symfony 3.0?
Hi,
I see this in the documentation of bundled example:
// Find the 5 nearest objects (15km) from the current user.
$objects = ObjectQuery::create()
->filterByDistanceFrom($result->getLatitude(), $result->getLongitude(), 15)
->limit(5)
->find();
I assume that this is propel..
There is a method to query the bundle of this type with doctrine?
Thanks
Hi,
When i try to get results from openstreetmap provider i only get one result each time.
I've tested this url : http://nominatim.openstreetmap.org/search?q=paris&format=xml&addressdetails=1&limit=5 and i get my 5 results
[{"place_id":"97923440","licence":"Data \u00a9 OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"relation","osm_id":"7444","boundingbox":["48.8155746459961","48.902156829834","2.22412180900574","2.46976041793823"],"lat":"48.8565056","lon":"2.3521334","display_name":"Paris, Ile-de-France, Metropolitan France","class":"place","type":"city","importance":0.96893459932191,"icon":"http:\/\/nominatim.openstreetmap.org\/images\/mapicons\/poi_place_city.p.20.png","address":{"city":"Paris","county":"Paris","state":"Ile-de-France","country_code":"fr"}},{"place_id":"97357969","licence":"Data \u00a9 OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"relation","osm_id":"71525","boundingbox":["48.8155746459961","48.902156829834","2.22412180900574","2.46976041793823"],"lat":"48.85886575","lon":"2.32003761177144","display_name":"Paris, Ile-de-France, Metropolitan France, France","class":"boundary","type":"administrative","importance":0.96893459932191,"icon":"http:\/\/nominatim.openstreetmap.org\/images\/mapicons\/poi_boundary_administrative.p.20.png","address":{"county":"Paris","state":"Ile-de-France","country":"France","country_code":"fr"}},{"place_id":"42637879","licence":"Data \u00a9 OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"way","osm_id":"33063046","boundingbox":["35.2672462463379","35.3065032958984","-93.7618103027344","-93.6750793457031"],"lat":"35.28687645","lon":"-93.7354879210082","display_name":"Paris, Logan County, Arkansas, United States of America","class":"place","type":"city","importance":0.67385884862688,"icon":"http:\/\/nominatim.openstreetmap.org\/images\/mapicons\/poi_place_city.p.20.png","address":{"city":"Paris","county":"Logan County","state":"Arkansas","country":"United States of America","country_code":"us"}},{"place_id":"42729434","licence":"Data \u00a9 OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"way","osm_id":"33299478","boundingbox":["33.6118507385254","33.7383804321289","-95.6279296875","-95.4354476928711"],"lat":"33.6751155","lon":"-95.5502662477703","display_name":"Paris, Lamar County, Texas, United States of America","class":"place","type":"city","importance":0.54374443751163,"icon":"http:\/\/nominatim.openstreetmap.org\/images\/mapicons\/poi_place_city.p.20.png","address":{"city":"Paris","county":"Lamar County","state":"Texas","country":"United States of America","country_code":"us"}},{"place_id":"97962432","licence":"Data \u00a9 OpenStreetMap contributors, ODbL 1.0. http:\/\/www.openstreetmap.org\/copyright","osm_type":"relation","osm_id":"130722","boundingbox":["38.1649208068848","38.2382736206055","-84.3073272705078","-84.2320861816406"],"lat":"38.2097987","lon":"-84.2529869","display_name":"Paris, Bourbon County, Kentucky, United States of America","class":"place","type":"city","importance":0.5108263210417,"icon":"http:\/\/nominatim.openstreetmap.org\/images\/mapicons\/poi_place_city.p.20.png","address":{"city":"Paris","county":"Bourbon County","state":"Kentucky","country":"United States of America","country_code":"us"}}]
If i try getting the same results with this code :
$address = $this->container
->get('bazinga_geocoder.geocoder')
->using('openstreetmap')
->geocode('paris');
I get:
Geocoder\Result\Geocoded::__set_state(array(
'latitude' => 48.8565056,
'longitude' => 2.3521334,
'bounds' =>
array (
'south' => 48.815574646,
'west' => 2.22412180901,
'north' => 48.9021568298,
'east' => 2.46976041794,
),
'streetNumber' => NULL,
'streetName' => NULL,
'cityDistrict' => NULL,
'city' => 'Paris',
'zipcode' => NULL,
'county' => 'Paris',
'countyCode' => NULL,
'region' => 'Île-De-France',
'regionCode' => NULL,
'country' => NULL,
'countryCode' => 'FR',
'timezone' => NULL,
))
I ran some test on Geocoder.php especially in geocode method. After this line
$data = $provider->getGeocodedData(trim($value));
However after the next line
$result = $this->returnResult($data);
Let me know if i made a mistake in my geocode call or if it's a real issue.
So far i only tried the openStreetMap provider so i can't tell if this happens to all providers.
With Symfony 3.1 a whole new range of PSR-6 compatible cache adapters have come to our disposal. Unfortunately the Cache provider in this bundle only accepts caches that implement Doctrine\Common\Cache\Cache
and Doctrine Cache has not jumped on the PSR-6 wagon.
With this issue I'd like to open up a discussion how to facilitate the usage of PSR-6 compatible caches. I see a number of possibilities:
Bazinga\Bundle\GeocoderBundle\Provider\Cache
to support both doctrine and PSR-6 caches. (Maybe not really a SOLID solution).Also I noticed geocoder-php/Geocoder#512.
HTTPPlug allows using a PSR-6 compatible cache plugin (http://docs.php-http.org/en/latest/plugins/cache.html) so another option altogether might be to delegate the caching to the Geocoder library itself.
I'd like to hear your ideas.
This bundle will get some love this summer with Geocoder 4.0.
I suggest to be brave here. I think we should require Syfmony 3.3 with all the great features that includes. What do you think?
Older projects will still be able to use the previous versions.
I guess this needs to be added in geocoder too, I haven't checked, but in the bundle I see that for maxmind_binary there is a binary_file param but that's it so there is no way to add the ipv6 DB.
Version 4 broke Symfony 2.1
ErrorException: Catchable Fatal Error: Argument 1 passed to Bazinga\Bundle\GeocoderBundle\Logger\GeocoderLogger::__construct() must be an instance of Psr\Log\LoggerInterface, instance of Symfony\Bridge\Monolog\Logger given, called in \app\cache\dev\appDevDebugProjectContainer.php on line 253 and defined in \vendor\willdurand\geocoder-bundle\Bazinga\Bundle\GeocoderBundle\Logger\GeocoderLogger.php line 34
Version 2.1 LoggerInterface used from Symfony framework not PSR,
Having a GeoIP provider with locally stored database would help developers on Windows, where compiling anything can be a real nightmare. It's also nice to have a provider that, while being slower, doesn't depend on remote API calls, PECL packages, PHP/Apache modules and is fully platform-independent.
The configuration would accept 2 parameters, one that points to a locally stored PHP API, and the other to a database file.
The new GeoIP2Database provider seem to be the answer problem we have. But there is no way to add it with the bundle. Can it be added?
In the last 3.x version, cached data is serialized from Geocoder 2 results (arrays)
In the actual 4.x version, data is a serialized AddressCollection
The result is : Catchable Fatal Error: Argument 4 passed to Bazinga\Bundle\GeocoderBundle\Logger\GeocoderLogger::logRequest() must be an instance of Geocoder\Model\AddressCollection, array given
Unfortunately, this is a BC sometimes difficult to handle (for example with an empty cache)
I may suggest, for new future major releases, using one of this tricks :
change the cache key name by including a version number
$key = 'geocoder_v4_'.sha1($this->locale.$address);
change the cache key sha1 including a version number
$key = 'geocoder_'.sha1($this->cacheDataVersion.$this->locale.$address);
assert cache data is formatted as expected
if (false !== $data = $this->cache->fetch($key)) {
$result = unserialize($data);
if ($result instanceof AddressCollection) {
return $result;
}
}
or maybe ensure retro compat ?
What is your opinion ?
Since the latest stable requires willdurand/geocoder: ~2.5
we can not profit from the the new geocoder v3. Is there any plan to release a new release from master?
If there are any tickets and and pull requests needed to finish the new release you may tag them with a intended version milestone, so everyone knows where to help?
Hi,
I am actually trying to make reverse geocoding with google maps. But, I did not find any example in the documentations of BazingaGeocoderBundle.
Could you please give me an example or a link to a documentation?
Thanks,
Does this bundle exposes the Geonames provider? Because from the Geocoder documentation it says it has a provider named geonames (https://github.com/geocoder-php/Geocoder#address-based-providers), but in the bundle configuration such name cannot be found.
How do I create multiple 'chain' providers so I can have multiple configurations with different priorities? (which is how its supposed to be used).
@willdurand, I see that there is no option to set api key for google_maps
provider. There is possibility to increase requests quota, which I currently need. I think that not required option should be added.
I want to add more data into geocode result but dont know if its possible to extend ResultFactory
I have implemented my own provider which returns more data but now my problem is ResultFactory which is default Geocoded
Regards
I am using BazingaGeocoderBundle in reverse geocoding the (X,Y) coordinates. Since, my website is bilingual, I do need to make reverse geocoding twice.
Unfortunately, the configuration of BazingaGeocoderBundle allows you to set only one locale as it is seen in the code below. So, I am wondering if it is possible to set the locale
while coding (not in the config.yml)?
bazinga_geocoder:
providers:
google_maps:
locale: fr_FR
region: ~
use_ssl: false
Notice: Undefined index: country_name in /var/www/html/vendor/willdurand/geocoder/src/Geocoder/Provider/GeoIPsProvider.php line 124
Hi,
I see there is no support for the GoogleMapsBusinessProvider via the bazinga_geocoder.providers configuration.
Right now I'm using this as a fix:
services:
bazinga_geocoder.http_adapter.buzz:
class: Geocoder\HttpAdapter\BuzzHttpAdapter
bazinga_geocoder.provider.google_maps_business:
class: Geocoder\Provider\GoogleMapsBusinessProvider
arguments: [@bazinga_geocoder.http_adapter.buzz, "gme-client-id", "private-key"]
Then in the Controller:
$geocoder = $this->get('bazinga_geocoder.geocoder');
$geocoder->registerProvider($this->get('bazinga_geocoder.provider.google_maps_business'));
$result = $geocoder->using('google_maps_business')->geocode('Rua Santo Henrique, 916');
But I would love to see this:
bazinga_geocoder:
providers:
google_maps_business:
client_id: ""
private_key: ""
and then in the Controller:
$result = $this->get('bazinga_geocoder.geocoder')->using('google_maps_business')->geocode('Rua Santo Henrique, 916');
I would love to help with that, but I'm kinda of a GitHub newbie, if you guys could teach me the necessary steps I'd apreciate. :D
Heyho...
i am wondering for a time now why i am getting "Could not execute query" exception with googleMaps, but if I type the query manuel there are correct results.
After a while of debugging i found the solution(the problem) in the curl-request:
"SSL certificate problem: "unable to get local issuer certificate"
Wouldn't it be nice or a better errordescription if this would be the text instead of simply just "Could not execute query"?
Maybe this issue-ticket will help others ;)
Best regards,
Florian Scholz
It seems there is problem between Bazinga Geocoder @stable and Symfony 2.3.3
ContextErrorException: Warning: Invalid argument supplied for foreach() in /home/www/website/www/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php line 145
in /home/www/website/www/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php line 145
at ErrorHandler->handle('2', 'Invalid argument supplied for foreach()', '/home/www/website/www/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php', '145', array('definition' => object(Definition), 'id' => 'bazinga_geocoder.event_listener.fake_request', 'parent' => object(DOMElement), 'service' => object(DOMElement), 'scope' => 'container', 'name' => '0', 'tags' => array('event' => 'kernel.request', 'method' => 'onKernelRequest', 'priority' => '128'), 'attributes' => 'kernel.request', 'tag' => object(DOMElement))) in /home/www/website/www/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php line 145
at XmlDumper->addService(object(Definition), 'bazinga_geocoder.event_listener.fake_request', object(DOMElement)) in /home/www/website/www/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php line 214
at XmlDumper->addServices(object(DOMElement)) in /home/www/website/www/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Dumper/XmlDumper.php line 55
at XmlDumper->dump() in /home/www/website/www/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php line 34
at ContainerBuilderDebugDumpPass->process(object(ContainerBuilder)) in /home/www/website/www/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php line 119
at Compiler->compile(object(ContainerBuilder)) in /home/www/website/www/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php line 629
at ContainerBuilder->compile() in /home/www/website/www/app/bootstrap.php.cache line 2397
at Kernel->initializeContainer() in /home/www/website/www/app/bootstrap.php.cache line 2177
at Kernel->boot() in /home/www/website/www/app/bootstrap.php.cache line 2208
at Kernel->handle(object(Request)) in /home/www/website/www/web/app_dev.php line 28
Our server is behind a firefall and access to the internet is only available via proxy. Is there a way to specify proxy settings for the Geocoder HTTPAdapters?
Hi,
I'm under Symfony 2.2, and the geolocalisation keep failing (it tries to geolocate them with the ip "Localhost" (i guess 127.0.0.1).
I do have Varnish / Apache (on the same server).
I configure the trusted_proxies. ( trusted_proxies: ['127.0.0.1']
)
And under my default.vcl i've added:
backend default {
.host = "127.0.0.1";
.port = "8080";
}
sub vcl_recv {
remove req.http.X-Forwarded-For;
set req.http.X-Forwarded-For = client.ip;
if (req.http.Cache-Control ~ "no-cache") {
return (pass);
}
set req.http.Surrogate-Capability = "abc=ESI/1.0";
}
sub vcl_fetch {
if (beresp.http.Surrogate-Control ~ "ESI/1.0") {
unset beresp.http.Surrogate-Control;
set beresp.do_esi = true;
}
}
Does that rings a bell ?
Thanks.
Hello,
I want to extend the GoogleMaps provider to add an ability to manipulate handling of an address parameter. In order to make this possible a new service should be created with overridden geocode method. However the method uses a private method executeQuery, also this method uses another private method updateAddressComponent. It looks like when the GoogleMapsBusiness provider was created, method buildQuery of the GoogleMaps provider was changed to protected to extend it in GoogleMapsBusiness. Can these private methods be changed to protected to extend the provider more fully?
I am planning to make a reverse geocoding based on the BazingaGeocoderBundle. A simple way to do that is write this simple code in the controller:
$result = $this->container
->get('bazinga_geocoder.geocoder')
->using('google_maps')
->reverse(48.79084170157100,2.42479377175290);
return $this->render("MinnAdsBundle:Motors:test.html.twig",
array('result'=>var_dump($result)));
Until here, things are going well.
My objective is to make the code nicer & resuable. So, I used this article to write my own GeocoderEventSubscriber as describer below:
<?php
namespace Minn\AdsBundle\Doctrine\Event;
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Doctrine\ORM\Event\LifecycleEventArgs;
//use Geocoder\Provider\ProviderInterface;
use Bazinga\Bundle\GeocoderBundle\Geocoder\LoggableGeocoder;
/**
* Subscribes to Doctrine prePersist and preUpdate to update an
* the address components of a MotorsAds entity
*
* @author majallouli
*/
class MotorsAdsGeocoderEventSubscriber implements EventSubscriber {
protected $geocoder;
public function __construct(LoggableGeocoder $geocoder){
$this->geocoder = $geocoder;
}
/**
* Specifies the list of events to listen
*
* @return array
*/
public function getSubscribedEvents(){
return array(
'prePersist',
'preUpdate',
);
}
/**
* Sets a new MotorsAds's address components if not present
*
* @param LifecycleEventArgs $eventArgs
*/
public function prePersist(LifecycleEventArgs $eventArgs){
$motorsAds = $eventArgs->getEntity();
if($motorsAds instanceof \Minn\AdsBundle\Entity\MotorsAds){
if( !$motorsAds->getCountry()){
$em = $eventArgs->getEntityManager();
$this->geocodeMotorsAds($motorsAds,$em);
}
}
}
/**
* Sets an updating MotorsAds's address components if not present
* or any part of address updated
*
* @param PreUpdateEventArgs $eventArgs
*/
public function preUpdate(PreUpdateEventArgs $eventArgs){
$motorsAds = $eventArgs->getEntity();
if($motorsAds instanceof \Minn\AdsBundle\Entity\MotorsAds){
if( !$motorsAds->getCountry() ){
$em = $eventArgs->getEntityManager();
$this->geocodeMotorsAds($motorsAds,$em);
$uow = $em->getUnitOfWork();
$meta = $em->getClassMetadata(get_class($motorsAds));
$uow->recomputeSingleEntityChangeSet($meta, $motorsAds);
}
}
}
/**
* Geocode and set the MotorsAds's address components
*
* @param type $motorsAds
*/
private function geocodeMotorsAds($motorsAds,$em){
$result = $this->geocode
->using('google_maps')
->reverse($motorsAds->getLat(),$motorsAds->getLng());
$motorsAds->setCountry(
$em->getRepository("MinnAdsBundle:Country")->findCountryCode($result['countryCode']));
}
}
After that, I declared my EventSubscriber as a service:
services:
# ...
geocoder_motorsads.listener:
class: Minn\AdsBundle\Doctrine\Event\MotorsAdsGeocoderEventSubscriber
arguments: [@bazinga_geocoder.geocoder] # almost sure that the error is here!!
tags:
- { name: doctrine.event_subscriber }
Actually, I get this error:
ContextErrorException: Notice: Undefined property: Minn\AdsBundle\Doctrine\Event\MotorsAdsGeocoderEventSubscriber::$geocode in /home/amine/NetBeansProjects/tuto/src/Minn/AdsBundle/Doctrine/Event/MotorsAdsGeocoderEventSubscriber.php line 78
I am almost sure that error is in the declaration of arguments of the EventSubscriber. Is it @bazinga_geocoder.geocoder
?
Thank you for your help!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.