Problem/Motivation
On \Drupal\commerce_dashboard\Plugin\rest\resource\CommerceDashboardResource, we have several calls to the \Drupal static container methods. These should be avoided where possible in classes, and dependency injection should be used instead.
This is the output from running drupal-check against the module:
drupal-check -ad web/modules/contrib/commerce_dashboard/
3/3 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
------ ------------------------------------------------------------------------------
Line src/Plugin/rest/resource/CommerceDashboardResource.php
------ ------------------------------------------------------------------------------
43 \Drupal calls should be avoided in classes, use dependency injection instead
48 \Drupal calls should be avoided in classes, use dependency injection instead
107 \Drupal calls should be avoided in classes, use dependency injection instead
126 \Drupal calls should be avoided in classes, use dependency injection instead
131 \Drupal calls should be avoided in classes, use dependency injection instead
------ ------------------------------------------------------------------------------
[ERROR] Found 5 errors
Proposed resolution
Use dependency injection in \Drupal\commerce_dashboard\Plugin\rest\resource\CommerceDashboardResource.
Remaining tasks
Add dependency injection to class.
User interface changes
None.
API changes
None.
Data model changes
None.
Comments
Comment #2
gueguerreiroThis patch adds dependency dependency injection and replaces all \Drupal calls.
Comment #3
gueguerreiroComment #5
nikolai fischer commentedThank you