d8-contrib-modules / cloudflare

Cloudflare Module for Drupal
16 stars 14 forks source link

Use dependency injection #16

Closed wimleers closed 9 years ago

wimleers commented 9 years ago

Business Requirements

This module currently very much uses a D7 pattern, of using \Drupal::config() (~ variable_get()) and then instantiating objects all over the place.

Instead of exposing services that have their configuration injected, and those services can then be injected again, without every piece of code needing to retrieve the configuration and instantiate such an object again with that configuration.

Clear example of this: https://github.com/wimleers/cloudflare/commit/3281a7d74033b3ee2ab13834cd2bf24e327c62bc#diff-a35ab1b58293fa8fcf5e19b41a5f79e8L104.

aweingarten commented 9 years ago

@wimleers I love this suggestion! There is a similar issue on the SDK queue: https://github.com/d8-contrib-modules/cloudflarephpsdk/issues/12

Naive question: is there any major difference that you are aware of between Symphony and Drupal services/dependency injection.

wimleers commented 9 years ago

Drupal == Symfony in this regard.

aweingarten commented 9 years ago

I've done some cursory research from what I can tell it makes the most sense to implement the service in CloudFlare rather than PHPSDK due to the dependencies on CMI.

aweingarten commented 9 years ago

Merged code in