Merge pull request #3505 from woocommerce/PCP-4970-add-defensive-code-for-realpath-failures-in-module-service-files

Create a centralized service for a path to the main plugin file (4970)
This commit is contained in:
Niklas Gutberlet 2025-08-04 19:42:12 +02:00 committed by GitHub
commit 4a985fcb2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
64 changed files with 1374 additions and 796 deletions

View file

@ -87,15 +87,7 @@ return array(
);
},
'save-payment-methods.module.url' => static function ( ContainerInterface $container ): string {
/**
* The path cannot be false.
*
* @psalm-suppress PossiblyFalseArgument
*/
return plugins_url(
'/modules/ppcp-save-payment-methods/',
dirname( realpath( __FILE__ ), 3 ) . '/woocommerce-paypal-payments.php'
);
return plugins_url( '/modules/ppcp-save-payment-methods/', $container->get( 'ppcp.path-to-plugin-main-file' ) );
},
'save-payment-methods.endpoint.create-setup-token' => static function ( ContainerInterface $container ): CreateSetupToken {
return new CreateSetupToken(