/Drupal calls and t() calls should be avoided in classes.

Created on 13 August 2021, almost 3 years ago
Updated 19 June 2024, 7 days ago

Problem/Motivation

$ phpcs --standard=DrupalPractice .

FILE: /focal_point/src/Controller/FocalPointPreviewController.php
-----------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------
 265 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 266 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
-----------------------------------------------------------------------------------------------------------------


FILE: /focal_point/src/Plugin/Field/FieldWidget/FocalPointImageWidget.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
 51 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------


FILE: /focal_point/tests/src/Functional/FocalPointWidgetTest.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
 84 | 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

📌 Task
Status

Fixed

Version

1.0

Component

Other Code

Created by

🇮🇳India ankithashetty Karnataka, India

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024