\Drupal::entityTypeManager()->getStorage call should be avoided use dependency injection instead

Created on 15 May 2023, over 1 year ago
Updated 18 June 2023, over 1 year ago

Problem/Motivation

Module's code contains several Drupal Dependency Injection issues. This task is created to fix them.

Steps to reproduce

Run the command:
phpcs --standard=DrupalPractice web/modules/contrib/link_filebrowser/

Proposed resolution

Fix the following coding standards issues and upload the patch or create an MR with fixes.

FILE: \modules\contrib\link_filebrowser\src\Controller\LinkFileBrowserController.php
--------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------
 75 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
--------------------------------------------------------------------------------------------------------------------
๐Ÿ“Œ Task
Status

Closed: outdated

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia Shanu Chouhan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Shanu Chouhan
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Shanu Chouhan

    Here's a patch for it.

  • Status changed to RTBC over 1 year ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines kenyoOwen

    Hi Shanu Chouhan

    After running phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml link_filebrowser, I applied patch #2 to the โ€œLink file browserโ€ module and confirmed that the issue mentioned is resolved. Please see the screenshots attached.

    For your review.
    Thank you.

  • Status changed to Closed: outdated over 1 year ago
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance lazzyvn paris

    Oh this patch is not good
    for controller you don't have to use dependency injection it just use $this->entityTypeManager()

Production build 0.71.5 2024