Problem/Motivation
After running coder for Drupal Best Practices, I found the following issues regarding t() calls:
phpcs --standard=DrupalPractice .
FILE: /optional_end_date/src/Plugin/Field/FieldType/OptionalEndDateDateRangeItem.php
---------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
---------------------------------------------------------------------------------------------------------------------
52 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
73 | 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() and use \Drupal\Core\StringTranslation\StringTranslationTrait wherever required.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3138489-2.patch | 1009 bytes | ankithashetty |
Comments
Comment #2
ankithashettyReplaced
t()calls with$this->t()wherever needed in the following patch, please review.Thank you.
Comment #4
birk commentedI've committed your patch, thank you.