Use dependency injection instead of \Drupal:: global object

Created on 31 October 2019, over 5 years ago
Updated 27 February 2025, about 1 month ago

Problem/Motivation

When I `grep -rl -- \\Drupal:: .` from the module root (and ignore tests and procedural code) I get:

./src/ParagraphAccessControlHandler.php
./src/Entity/ParagraphsType.php
./src/Entity/Paragraph.php
./src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
./src/Plugin/Field/FieldWidget/ParagraphsWidget.php
./src/Plugin/Field/FieldFormatter/ParagraphsSummaryFormatter.php
./modules/paragraphs_library/src/Controller/LibraryItemController.php
./modules/paragraphs_library/src/Entity/LibraryItem.php

As stated in https://www.drupal.org/docs/8/api/services-and-dependency-injection/serv... we really ought to use Dependency Injection.

Proposed resolution

Update the code to use Dependency Injection.

Remaining tasks

Do we want this to be a META issue and break the task into smaller pieces?
Will we want or need to create additional tests?

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

N/A

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

🇺🇸United States vegantriathlete Lakewood, CO

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024