ExtensionPathResolver::getPath() strange advise

Created on 15 November 2022, almost 2 years ago
Updated 4 October 2023, 12 months ago

Problem/Motivation

I added version 8.x-3.17 to one of my projects. After scanning it reported 1 problem for a theme file:

Call to deprecated function drupal_get_path(). Deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use Drupal\Core\Extension\ExtensionPathResolver::getPath() instead.

When I updated my theme, my IDE squarked:

Non static method 'getPath' should not be called statically.

Indeed, this method is public function getPath.

If I run palantirnet/drupal-rector:0.13.1, I recieved "better" advise:

-define('THEME_PATH', base_path() . drupal_get_path('theme', 'mytheme'));
+define('THEME_PATH', base_path() . \Drupal::service('extension.list.theme')->getPath('mytheme'));

Proposed resolution

Perhaps the included rector version need bumping?

Upgrade_status: 8.x-3.17
Drupal version : 9.4.7
PHP version : 8.1.11

πŸ› Bug report
Status

Closed: works as designed

Version

3.17

Component

Code

Created by

πŸ‡―πŸ‡΅Japan tyler36 Osaka

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

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