Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 300668

[META] Replace t() calls inside of classes

$
0
0

Problem/Motivation

There's many places in core where t() function is used in classes without dependency injection.
It makes this classes hard to unit test because t() defined in core/includes/bootstrap.inc
Also it makes harder to get rid of this include in later core

The sniff is already enabled for Plugins, in phpcs.xml.dist

<rule ref="DrupalPractice.Objects.GlobalFunction">
    <include-pattern>*/Plugin/*</include-pattern>
  </rule>

Proposed resolution

Replace usage with one of following ways
- $this->t() for controllers using StringTranslationTrait or add if it's missing
- new TranslatableMarkup() in static methods

Remaining tasks

Final issue to enable the sniff and fix any remaining problems.
#3507043: Enable DrupalPractice.Objects.GlobalFunction

Cleanup

#3133726: [meta] Remove usage of t() in tests not testing translation

User interface changes

API changes

no

Data model changes

no

Release notes snippet

n/a


Viewing all articles
Browse latest Browse all 300668

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>