Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There are many advantages of using ControllerBase.
This issue removes the hidden dependency on global function l() and t() and improves testability.
Comment | File | Size | Author |
---|---|---|---|
#2 | interdiff-0-2.txt | 1.03 KB | martin107 |
#2 | use-ControllerBase-2.patch | 3.22 KB | martin107 |
use-ControllerBase.patch | 3.37 KB | rpayanm | |
Comments
Comment #2
martin107 CreditAttribution: martin107 commentedLocally I can reproduce the SimpleTestExampleTest failure on head so it is not this issue that is causing the break.
So I have fixed two nit picks before moving on to find/create a broken HEAD issue.
new Url('page_example_simple');
1) Looking at the Url constructor documentation it say it is only use this in extreme cases Url::fromRoute() is preferred because it is self documenting.
2) Converted one more t() into $this->t().
Updated issue summary to mention dependency injection.
Comment #3
Mile23Totally the way to go, since the base class and injected t() is the best-practice for this kind of thing.
Patch still applies... Let's see about the testbot.
Comment #6
Mile23Committed and pushed. Thanks!