t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead

Created on 1 April 2020, about 5 years ago
Updated 31 July 2024, 9 months ago
📌 Task
Status

Needs work

Version

1.0

Component

Code

Created by

🇳🇴Norway neslee canil pinto India

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

Comments & Activities

Not all content is available!

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

  • 🇨🇭Switzerland berdir Switzerland

    There are about 3 actual changes in PathautoTestHelperTrait that shouldn't use t() at all but just string concentation or something. Anything else is unrelated generated coding standards and addition of traits that already exist through the class hierarchy.

    1. +++ b/src/Form/PatternEditForm.php
      @@ -9,12 +9,15 @@ use Drupal\Core\Form\FormStateInterface;
        */
       class PatternEditForm extends EntityForm {
       
      +  use StringTranslationTrait;
      +
      

      EntityForm extends FormBase which has the trait already.

    2. +++ b/src/Form/PatternEditForm.php
      @@ -110,7 +113,7 @@ class PatternEditForm extends EntityForm {
       
      -    // if there is no type yet, stop here.
      +    // If there is no type yet, stop here.
           if ($this->entity->getType()) {
       
             $alias_type = $this->entity->getAliasType();
      @@ -121,7 +124,10 @@ class PatternEditForm extends EntityForm {
      
      @@ -121,7 +124,10 @@ class PatternEditForm extends EntityForm {
               '#default_value' => $this->entity->getPattern(),
               '#size' => 65,
               '#maxlength' => 1280,
      -        '#element_validate' => ['token_element_validate', 'pathauto_pattern_validate'],
      +        '#element_validate' => [
      +          'token_element_validate',
      +          'pathauto_pattern_validate',
      +        ],
      

      lots of unrelated changes in this file.

    3. +++ b/src/PathautoPatternListBuilder.php
      @@ -4,12 +4,15 @@ namespace Drupal\pathauto;
        * Provides a listing of Pathauto pattern entities.
        */
       class PathautoPatternListBuilder extends DraggableListBuilder {
       
      +  use StringTranslationTrait;
      +
      

      this already exists too.

Production build 0.71.5 2024