Problem/Motivation

Coming out of #3384835: Policy for semantic versioning

Proposed resolution

  1. Use auto-wiring for services. Some of the code in Mailer.php on this branch is useful.
  2. Mark these constructors as @internal - they may change in a minor/patch release.
  3. Create an easier system for plug-in DI??

#3 is a bit of a radical idea, however it could be something like this:

  • New class DiPluginBase extending PluginBase
  • Protected static variable $service_ids array of strings.
  • Static function create() gets these services from the container, creates the object, then calls protected function inject() passing array of services keyed by id. In case of derived classes, combine the arrays from all levels of the class hierarchy.
  • Protected function inject() default implementation saves to protected variable $services.
  • Protected function service($id) gets the service - just like the Drupal::service() function however with DI.
  • Net code added to use a new service = add string to an array. No BC impact to derived classes.

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

AdamPS created an issue. See original summary.

adamps’s picture

Title: Consider marking some classes @internal and find more convenient ways of dependency injection » Consider marking some classes/functions @internal and find more convenient ways of dependency injection
adamps’s picture

Issue summary: View changes
adamps’s picture

Version: 1.x-dev » 2.x-dev

adamps’s picture

Title: Consider marking some classes/functions @internal and find more convenient ways of dependency injection » Find more convenient ways of dependency injection and mark constructors as @internal
Status: Active » Needs review

  • adamps committed d059f150 on 2.x
    Issue #3391570 by adamps: Find more convenient ways of dependency...
adamps’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.