The apparent point of the class_resolver service in Drupal 8 is to allow classes to create their dependencies in such a way that the implementation can be swapped out. This would be a great thing to include in this module as well, for testing heavily OOP code (the Migrate module leaps to mind).

My use case is that I'm writing a complex migration which uses the Google REST API, and that requires me to create certain objects (like Google_Client, Google_Service_Drive, etc.) directly. Which makes things next to impossible to test. If I had a class resolver service, I could much more easily unit test the migration by swapping out the normal Google_Client and Google_Service_Drive objects with mocks.

Comments

phenaproxima created an issue. See original summary.

markhalliwell’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
markhalliwell’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev
Status: Active » Closed (outdated)

The 7.x-2.x branch was premature, this project has been deprecated in favor of https://www.drupal.org/project/backport.