Skip to content
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

Use dependency injection #16

Closed
4 tasks done
wimleers opened this issue Sep 14, 2015 · 4 comments
Closed
4 tasks done

Use dependency injection #16

wimleers opened this issue Sep 14, 2015 · 4 comments
Assignees

Comments

@wimleers
Copy link
Contributor

Business Requirements

  • As a developer I want to use a drupal module that uses PHP best practices like dependency injection.

Technical Requirements

  • Research Symphony and Drupal Services. See if it makes sense to implement API endpoints as symphony services
  • Update module to use service instead of raw calls to PHPSDK
  • Add any phpunit tests as necessary.

Background

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
Copy link
Contributor

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

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

@wimleers
Copy link
Contributor Author

Drupal == Symfony in this regard.

@aweingarten
Copy link
Contributor

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
Copy link
Contributor

Merged code in

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

No branches or pull requests

2 participants