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.

CommentFileSizeAuthor
#2 3138489-2.patch1009 bytesankithashetty

Comments

ankithashetty created an issue. See original summary.

ankithashetty’s picture

Status: Active » Needs review
StatusFileSize
new1009 bytes

Replaced t() calls with $this->t() wherever needed in the following patch, please review.

Thank you.

  • ankithashetty authored 00f760f on 8.x-1.x
    Issue #3138489 by ankithashetty: Avoid t() calls, instead use \Drupal\...
birk’s picture

Priority: Normal » Minor
Status: Needs review » Fixed

I've committed your patch, thank you.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.