mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
do only overwrite settings, which can be altered in current screen
This commit is contained in:
parent
bf1737a22e
commit
8fef1ec612
2 changed files with 9 additions and 2 deletions
|
@ -62,11 +62,12 @@ return [
|
||||||
$settings = $container->get('wcgateway.settings');
|
$settings = $container->get('wcgateway.settings');
|
||||||
$fields = $container->get('wcgateway.settings.fields');
|
$fields = $container->get('wcgateway.settings.fields');
|
||||||
$webhookRegistrar = $container->get('webhook.registrar');
|
$webhookRegistrar = $container->get('webhook.registrar');
|
||||||
|
$state = $container->get('onboarding.state');
|
||||||
|
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$cacheFactory = new CachePoolFactory($wpdb);
|
$cacheFactory = new CachePoolFactory($wpdb);
|
||||||
$pool = $cacheFactory->createCachePool('ppcp-token');
|
$pool = $cacheFactory->createCachePool('ppcp-token');
|
||||||
return new SettingsListener($settings, $fields, $webhookRegistrar, $pool);
|
return new SettingsListener($settings, $fields, $webhookRegistrar, $pool, $state);
|
||||||
},
|
},
|
||||||
'wcgateway.order-processor' => static function (ContainerInterface $container): OrderProcessor {
|
'wcgateway.order-processor' => static function (ContainerInterface $container): OrderProcessor {
|
||||||
|
|
||||||
|
|
|
@ -17,17 +17,20 @@ class SettingsListener
|
||||||
private $settingFields;
|
private $settingFields;
|
||||||
private $webhookRegistrar;
|
private $webhookRegistrar;
|
||||||
private $cache;
|
private $cache;
|
||||||
|
private $state;
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Settings $settings,
|
Settings $settings,
|
||||||
array $settingFields,
|
array $settingFields,
|
||||||
WebhookRegistrar $webhookRegistrar,
|
WebhookRegistrar $webhookRegistrar,
|
||||||
CacheInterface $cache
|
CacheInterface $cache,
|
||||||
|
State $state
|
||||||
) {
|
) {
|
||||||
|
|
||||||
$this->settings = $settings;
|
$this->settings = $settings;
|
||||||
$this->settingFields = $settingFields;
|
$this->settingFields = $settingFields;
|
||||||
$this->webhookRegistrar = $webhookRegistrar;
|
$this->webhookRegistrar = $webhookRegistrar;
|
||||||
$this->cache = $cache;
|
$this->cache = $cache;
|
||||||
|
$this->state = $state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listen()
|
public function listen()
|
||||||
|
@ -73,6 +76,9 @@ class SettingsListener
|
||||||
{
|
{
|
||||||
$settings = [];
|
$settings = [];
|
||||||
foreach ($this->settingFields as $key => $config) {
|
foreach ($this->settingFields as $key => $config) {
|
||||||
|
if (! in_array($this->state->currentState(), $config['screens'], true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
switch ($config['type']) {
|
switch ($config['type']) {
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
$settings[$key] = isset($rawData[$key]);
|
$settings[$key] = isset($rawData[$key]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue