Problem/Motivation
FILE: ...les/contrib/gravitas_countdown/src/Plugin/Block/GravitasCountdownBlock.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 31 WARNINGS AFFECTING 31 LINES
--------------------------------------------------------------------------------
149 | WARNING | File::load calls should be avoided in classes, use dependency
| | injection instead
156 | WARNING | File::load calls should be avoided in classes, use dependency
| | injection instead
175 | WARNING | File::load calls should be avoided in classes, use dependency
| | injection instead
190 | WARNING | File::load calls should be avoided in classes, use dependency
| | injection instead
219 | WARNING | \Drupal calls should be avoided in classes, use dependency
| | injection instead
224 | WARNING | File::load calls should be avoided in classes, use dependency
| | injection instead
--------------------------------------------------------------------------------
Steps to reproduce
Execute the command: phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,js,info,txt,md,yml,twig gravitas_countdown/
Proposed resolution
Add dependency injections.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 3362396-7.patch | 3.47 KB | shanu chouhan |
Issue fork gravitas_countdown-3362396
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
prabuela commentedComment #3
urvashi_vora commentedComment #4
prabuela commentedComment #5
urvashi_vora commentedI will work on this soon.
Comment #6
avpadernoComment #7
shanu chouhan commentedComment #8
shanu chouhan commentedHere's a patch for it.
Comment #9
urvashi_vora commentedI will review it.
Comment #10
urvashi_vora commentedReviewed the patch provided by @Shanu Chouhan. It applies cleanly and modifies the code appropriately.
I can confirm that no issues left for:
1. File::load calls should be avoided in classes, use dependency injection instead
2. \Drupal calls should be avoided in classes, use dependency injection instead
Thanks for the work. Moving it to RTBC.
Comment #11
sujan shrestha commentedThank you for the patch. I have implemented the patch file to use dependency injection instead of classes and also fixed the following error on the new version
Argument #1 ($file_storage) must be of type Drupal\Core\Entity\EntityStorageInterface, array given
Comment #12
sujan shrestha commentedComment #13
sujan shrestha commented