Skip to content

Files

Latest commit

658cecf · Nov 17, 2018

History

History
47 lines (39 loc) · 1.38 KB

plugins.md

File metadata and controls

47 lines (39 loc) · 1.38 KB

Plugins

<< Back to documentation index

Plugins lets you modify or take actions the Query or the result. There are a few plugins from the geocoder-php/plugin package like LimitPlugin, LoggerPlugin and CachePlugin. Some of them are supported in the configuration.

# config.yml
bazinga_geocoder:
  fake_ip:
    ip: '123.123.123.123' # Uses the FakeIpPlugin
  providers:
    acme:
      factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory
      cache: 'app.cache' # Uses the CachePlugin
      limit: 5           # Uses the LimitPlugin
      locale: 'sv'       # Uses the LocalePlugin
      logger: 'logger'   # Uses the LoggerPlugin

To use a any other plugins you must first register them as a service. Say you want to add some data to each query. You may then use the QueryDataPlugin.

# services.yml
sevices:
  app.query_data_plugin:
    class: Geocoder\Plugin\Plugin\QueryDataPlugin
    arguments:
      - ['foo': 'bar']
      - true
# config.yml
bazinga_geocoder:
  providers:
    acme:
      factory: Bazinga\GeocoderBundle\ProviderFactory\GoogleMapsFactory
      plugins:
        - "app.query_data_plugin"

This will execute $query = $query->withData('foo', 'bar'); on all queries executed by the acme provider.

Read more about plugins at the Geocoder's documentation.