- Issue created by @vishalkhode
- First commit to issue fork.
While addressing the PHPCS/PHPStan errors as part of ticket: 📌 Fix validate pipeline Needs review , a PHPStan ignore line was added for the following service call:
\Drupal::service("extension.list.$type")->getPathname($name);
To improve the codebase and adhere to best practices, we should replace this direct service call with the extension.path.resolver
service object. This service object accepts extension_type
and extension_name
as arguments for method getPathName
and returns the correct pathname, which aligns with our goal of fixing PHPStan error of avoiding \Drupal::service calls in the classes and increasing code maintainability.
config_update.config_list
service definition to adds the extension.path.resolver
service ias the last argument.ConfigLister
class constructor to accept the extension.path.resolver
service object.listProvidedItems
method of ConfigLister
class and update \Drupal::service("extension.list.$type")
service object.ConfigListerWithProviders
class constructor to include the extension.path.resolver
service argument.ConfigListerWithProviders
class if it wasn't already.The ConfigLister
class is a base class, and the ConfigListerWithProviders
class extends it. Given that other contributed or custom modules might also have extended the ConfigLister
class, so we should not make the extension.path.resolver
service object a required argument in the ConfigLister
class constructor. Instead, we should make it optional for now and include a deprecation notice stating that calling the __construct
method of the ConfigLister
class without passing the extension.path.resolver
Active
2.0
Base module