Problem/Motivation

There are many places in PrintController where services are loaded statically, and configs are fetched statically. Those should be replaced with dependency injection. This is considered as a good practice. Sources: https://docs.acquia.com/articles/drupal-8-dependency-injection, https://www.drupal.org/docs/8/api/services-and-dependency-injection/serv...

Proposed resolution

Replace the static usages of:

  • \Drupal::service('renderer')
  • \Drupal::service('plugin.manager.mail')
  • \Drupal::config()
  • \Drupal::currentUser()
  • \Drupal::logger('commerce_pos_receipt')
  • \Drupal::service('module_handler')
  • \Drupal::service('commerce_price.number_formatter_factory')
  • \Drupal::entityTypeManager()

with dependecy injection.

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

CommentFileSizeAuthor
#2 2935348-2.patch9.03 KBalexpott

Comments

subhojit777 created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
StatusFileSize
new9.03 KB

I've done this. Whilst doing looking at the log channel stuff I've realised the calls to the log channel are incorrect. They shouldn't be translated and they shouldn't have the variables already replaced.

alexpott’s picture

Status: Needs review » Postponed

Let's postpone this on #2935465: Receipt flow potential leaves order unplaced as that issue extensively rewrites PrintController into something a bit smaller anyway.