mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
If the new settings module is not enabled, return null
This will force the `Settings` old class to always fallback to the old settings value
This commit is contained in:
parent
c8d9a142ea
commit
7dc2fef1da
1 changed files with 19 additions and 1 deletions
|
@ -74,6 +74,13 @@ class SettingsMapHelper {
|
|||
*/
|
||||
protected GeneralSettingsMapHelper $general_settings_map_helper;
|
||||
|
||||
/**
|
||||
* Whether the new settings module is enabled.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $new_settings_module_enabled;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -82,6 +89,7 @@ class SettingsMapHelper {
|
|||
* @param SettingsTabMapHelper $settings_tab_map_helper A helper for mapping the old/new settings tab settings.
|
||||
* @param SubscriptionSettingsMapHelper $subscription_map_helper A helper for mapping old and new subscription settings.
|
||||
* @param GeneralSettingsMapHelper $general_settings_map_helper A helper for mapping old and new general settings.
|
||||
* @param bool $new_settings_module_enabled Whether the new settings module is enabled.
|
||||
* @throws RuntimeException When an old key has multiple mappings.
|
||||
*/
|
||||
public function __construct(
|
||||
|
@ -89,7 +97,8 @@ class SettingsMapHelper {
|
|||
StylingSettingsMapHelper $styling_settings_map_helper,
|
||||
SettingsTabMapHelper $settings_tab_map_helper,
|
||||
SubscriptionSettingsMapHelper $subscription_map_helper,
|
||||
GeneralSettingsMapHelper $general_settings_map_helper
|
||||
GeneralSettingsMapHelper $general_settings_map_helper,
|
||||
bool $new_settings_module_enabled
|
||||
) {
|
||||
$this->validate_settings_map( $settings_map );
|
||||
$this->settings_map = $settings_map;
|
||||
|
@ -97,6 +106,7 @@ class SettingsMapHelper {
|
|||
$this->settings_tab_map_helper = $settings_tab_map_helper;
|
||||
$this->subscription_map_helper = $subscription_map_helper;
|
||||
$this->general_settings_map_helper = $general_settings_map_helper;
|
||||
$this->new_settings_module_enabled = $new_settings_module_enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,6 +136,10 @@ class SettingsMapHelper {
|
|||
* @return mixed|null The value of the mapped setting, or null if not found.
|
||||
*/
|
||||
public function mapped_value( string $old_key ) {
|
||||
if ( ! $this->new_settings_module_enabled ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->ensure_map_initialized();
|
||||
if ( ! isset( $this->key_to_model[ $old_key ] ) ) {
|
||||
return null;
|
||||
|
@ -149,6 +163,10 @@ class SettingsMapHelper {
|
|||
* @return bool True if the key exists in the new settings, false otherwise.
|
||||
*/
|
||||
public function has_mapped_key( string $old_key ) : bool {
|
||||
if ( ! $this->new_settings_module_enabled ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->ensure_map_initialized();
|
||||
|
||||
return isset( $this->key_to_model[ $old_key ] );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue