Problem/Motivation

Follow up #2729597: [meta] Replace \Drupal with injected services where appropriate in core

Proposed resolution

Replace all of them with IoC injection where possible

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

Hardik_Patel_12 created an issue. See original summary.

hardik_patel_12’s picture

StatusFileSize
new4.44 KB

Kindly review a patch.

Status: Needs review » Needs work

The last submitted patch, 2: 3158764-2.patch, failed testing. View results

hardik_patel_12’s picture

Status: Needs work » Needs review

Random failed test case, retesting the patch.

longwave’s picture

Status: Needs review » Needs work

Not sure we should be injecting the state service into ProviderRepository if we only need it for the purposes of a test.

If we really want to remove \Drupal::state() here we can inject the service in MediaTestOembedServiceProvider instead, either by extending the constructor or using setter injection.

hardik_patel_12’s picture

Status: Needs work » Needs review
StatusFileSize
new4.88 KB

@longwave , thankyou for review . Removing state injected service from ProviderRepository class from last patch.

There more instances that can be injected:

grep -nri '\Drupal::state()' core | grep -v .module | grep -vi test | grep -v .api.php | grep -v authorize.php | grep -v .inc
core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php:
321:$optimize_js = !defined('MAINTENANCE_MODE') && !\Drupal::state()->get('system.maintenance_mode') && $this->config->get('js.preprocess');
core/lib/Drupal/Core/Updater/Theme.php:52:    $themes = \Drupal::state()->get('system.theme.files', []);

Injecting state service in HtmlResponseAttachmentsProcessor file , but for Theme.php i am not sure because it is not using create menthod neither it is service.

Kindly review a new patch.

Status: Needs review » Needs work

The last submitted patch, 6: 3158764-6.patch, failed testing. View results

jungle’s picture

Status: Needs work » Closed (duplicate)

Thanks everyone for working on this, this is a duplicate of #3123228: Replace non-test usages of \Drupal::state() with IoC injection, which was filed earlier than this.