Problem/Motivation
$ phpcs --standard=DrupalPractice .
FILE: /var/www/html/drupal_contrib/web/modules/custom/faker_generate/src/Form/FakerGenerateContentForm.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 9 WARNINGS AFFECTING 9 LINES
------------------------------------------------------------------------------------------------------------------------------------------
20 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
35 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
60 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
83 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
88 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
112 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
114 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
115 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
116 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------Proposed resolution
Use dependency injection instead of /Drupal calls and use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead of t() calls.
User interface changes
NONE
API changes
NONE
Data model changes
NONE
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3166376-2.patch | 5.08 KB | ankithashetty |
Comments
Comment #2
ankithashettyReplaced t() calls with $this->t() and used depedency injection in the following patch, please review.
Thank you.
Comment #3
gaurav.kapoor commentedThanks for working on this.
Comment #5
gaurav.kapoor commented