Problem/Motivation

FILE: /var/www/html/vb/d_cont/mosparo_integration/src/Service/MosparoService.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
116 | WARNING | \Drupal calls should be avoided in classes, use dependency
| | injection instead
--------------------------------------------------------------------------------

FILE: ...ion/modules/mosparo_contact/src/Plugin/Field/FieldWidget/MosparoWidget.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------
33 | WARNING | \Drupal calls should be avoided in classes, use dependency
| | injection instead
34 | WARNING | \Drupal calls should be avoided in classes, use dependency
| | injection instead
--------------------------------------------------------------------------------

Time: 372ms; Memory: 12MB

Steps to reproduce

Execute the command: phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig mosparo_integration/

Remaining tasks

Patch review

CommentFileSizeAuthor
dependency-injection-fixed.patch4.24 KBurvashi_vora
Command icon 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

urvashi_vora created an issue. See original summary.

zepich’s picture

Assigned: Unassigned » zepich

  • zepich committed 09d30b6f on 1.0.x
    Issue #3372740: \Drupal calls should be avoided in classes, use...
zepich’s picture

Hi @urvashi_vora

Thank you very much for your issue and the patch.

I've reviewed it and adjusted it. In my eyes, we cannot replace the \Drupal call in the MosparoWidget because it uses the constructor method from WidgetBase which is not able to accept Dependency Injection (https://git.drupalcode.org/project/mosparo_integration/-/blob/1.0.x/modu...).

I'm open to suggestions if you know how we could solve that. We have the same problem in the other module (https://git.drupalcode.org/project/mosparo_integration/-/blob/1.0.x/modu...) which the CodeSniffer didn't found.

Thank you very much, and have a nice day!

Kind regards,

zepich

zepich’s picture

Status: Needs review » Fixed

I fixed one \Drupal usage. The other uses are not fixable in my view.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.