Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
After running coder for Drupal best practices, I found the following issues regarding t() calls:
FILE: /advancedqueue/src/Plugin/AdvancedQueue/Backend/BackendBase.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------------------------
103 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
104 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------
FILE: /advancedqueue/src/Form/QueueForm.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------------------------
123 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
124 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------
FILE: /advancedqueue/src/QueueListBuilder.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
53 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------
Proposed resolution
Need to replace t() calls with $this->t() wherever required.
Comment | File | Size | Author |
---|---|---|---|
#3 | 3156680-3.patch | 3.03 KB | andypost |
| |||
#3 | interdiff.txt | 1.03 KB | andypost |
#2 | 3156680-2.patch | 2 KB | ankithashetty |
|
Comments
Comment #2
ankithashettyReplaced
t()
calls with$this->t()
wherever needed in the following patch, please review.Thank you.
Comment #3
andypostFixed remains
Comment #4
jonathanshawComment #5
jcnventura CreditAttribution: jcnventura at 1xINTERNET commentedThanks for the patch!
Comment #7
jcnventura CreditAttribution: jcnventura at 1xINTERNET commented