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.
\Drupal::currentUser() static methods should be avoided in classes, use dependency injection instead.
Comment | File | Size | Author |
---|---|---|---|
#8 | avoid_static_call-2910127-1.patch | 3.18 KB | bapi_22 |
Comments
Comment #2
bapi_22 CreditAttribution: bapi_22 at Cybage Software Pvt Ltd. commentedComment #3
iStryker CreditAttribution: iStryker commentedCan you explain this a little more, maybe link to documentation that talks about Avoiding static calls inside a class method.
Comment #4
bapi_22 CreditAttribution: bapi_22 at Cybage Software Pvt Ltd. commentedHi iStryker,
Please go through the acquia documentation using below link.
https://docs.acquia.com/article/lesson-83-dependency-injection
Comment #5
iStryker CreditAttribution: iStryker commentedI am getting this error when I run the test
Drupal\Tests\draggableviews\Functional\DraggableviewsTest::testDraggableviewsContent
TypeError: Argument 1 passed to Drupal\draggableviews\Plugin\views\field\DraggableViewsField::__construct() must be a
n instance of Drupal\draggableviews\Plugin\views\field\AccountInterface, instance of Drupal\Core\Session\AccountProxy
given, called in /var/www/drupal8/modules/draggableviews/src/Plugin/views/field/DraggableViewsField.php on line 41
Comment #6
iStryker CreditAttribution: iStryker commentedIt actually throws error install Draggableview Demo module
Comment #7
bapi_22 CreditAttribution: bapi_22 at Cybage Software Pvt Ltd. commentedI didn't checked at my end. Let check and will get back to you.
Comment #8
bapi_22 CreditAttribution: bapi_22 at Cybage Software Pvt Ltd. commentedHi Tyler Struyk,
It was good catch. I was forgot to inject the EntityManager and LanguageManager from the parent Class.
Please use updated patch.
Comment #10
iStryker CreditAttribution: iStryker commentedLittle clean up with Code standard checker and committed.