Error message

You need to log in or create an account to access this page.

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

CommentFileSizeAuthor
#4 3123212-4.patch2.78 KBcodersukanta

Comments

jungle created an issue. See original summary.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

codersukanta’s picture

Assigned: Unassigned » codersukanta
codersukanta’s picture

Assigned: codersukanta » Unassigned
Status: Active » Needs review
StatusFileSize
new2.78 KB
hardik_patel_12’s picture

Thanks for working on this.

	-   $redirect = \Drupal::pathValidator()->getUrlIfValid($options['path']);
               +   $redirect = \Drupal::service('path.validator')->getUrlIfValid($options['path']);

It's not just replacing \Drupal::pathValidator() with \Drupal::service('path.validator') , but

It's to replace \Drupal::pathValidator() and \Drupal::service('path.validator') with IoC injection where possible.

Kindly see the Parent issue for more info.

hardik_patel_12’s picture

Seems nothing to do.

jungle’s picture

Title: Replace usages of \Drupal::pathValidator() with IoC injection » Replace non-test usages of \Drupal::pathValidator() with IoC injection

We do this for non-test code under this issue.

Per the parent issue, rescoping this to do it for non-test code. Sorry for the change!

jungle’s picture

Status: Needs review » Closed (works as designed)
  git grep -ni '\Drupal::pathValidator' core
core/includes/batch.inc:511:          $redirect = \Drupal::pathValidator()->getUrlIfValid($options['path']);
core/lib/Drupal/Core/Url.php:433:    $url = \Drupal::pathValidator()
core/modules/aggregator/aggregator.module:18:      $path_validator = \Drupal::pathValidator();
core/tests/Drupal/Tests/Core/DrupalTest.php:423:    $this->assertNotNull(\Drupal::pathValidator());

It kooks like that only in scope one is in core/lib/Drupal/Core/Url.php, but it's in protected static function fromInternalUri()

To me, there is nothing to do. Thanks all for your efforts!