Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Adding Plugin support #742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 1, 2017
Merged

Adding Plugin support #742

merged 5 commits into from
Aug 1, 2017

Conversation

Nyholm
Copy link
Member

@Nyholm Nyholm commented Jul 15, 2017

When creating the BazingaBundle we could either decorate all providers with a CacheProvider, LoggerProvider, ProfilingProvider etc... or we could use a PluginProfiler. This basically rips all nice plugin classes created by php-http and modify them to our needs.

I put these plugin files in a new package, geocoder-php/plugin, because they have a few external dependencies.

I've added 6 plugins to modify or log the queries.

FYI @joelwurtz, @sagikazarmark

(Blocked by #741)

Usage

$provider = new GoogleMapsProvider();
$pluginProvider = new PluginProvider($provider, [
  new LocalePlugin('sv'),
  new CachePlugin($cacheService),
  new LoggerPlugin($logger),
]);

$query = GeocodeQuery::create('foobar');
$result = $pluginProvider->geocodeQuery($query);

// $result is in Swedish
// $result is cached
// $result is logged

// Try again
$result = $pluginProvider->geocodeQuery($query);

// $result is fetched from cache and not log were written. 

@willdurand
Copy link
Member

I would reschedule this feature for version 4.1.0. I like the idea but not sure if it is the right approach. For instance, we could have some features built-in in the core.

@Nyholm
Copy link
Member Author

Nyholm commented Jul 15, 2017

Yeah, this is no blocker for 4.0.0. It only blocks the work on the bundle.

For instance, we could have some features built-in in the core.

What do you mean? We already have the StatefulGeocoder which adds bounds, locale, limit etc. We do also have a CacheProvider. The only new feature this bing is the method how we add things and the possibility to allow users and other library to add features.

@Nyholm Nyholm modified the milestones: 4.1.0, 4.0.0 Jul 15, 2017
@arubacao
Copy link
Contributor

👍 for Decorator Pattern

@Nyholm
Copy link
Member Author

Nyholm commented Aug 1, 2017

You can see the need for this package in: geocoder-php/BazingaGeocoderBundle#150

I want to move forward with this new package. Does anyone have an argument why this should not be created?

@willdurand
Copy link
Member

I want to move forward with this new package. Does anyone have an argument why this should not be created?

Let's do it!

@Nyholm Nyholm merged commit 4af0c20 into geocoder-php:master Aug 1, 2017
@Nyholm Nyholm deleted the plugin branch August 1, 2017 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants