mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
clear cache when changing settings
This commit is contained in:
parent
8388644906
commit
7fb1e25ad8
2 changed files with 13 additions and 2 deletions
|
@ -61,7 +61,11 @@ return [
|
|||
$settings = $container->get('wcgateway.settings');
|
||||
$fields = $container->get('wcgateway.settings.fields');
|
||||
$webhookRegistrar = $container->get('webhook.registrar');
|
||||
return new SettingsListener($settings, $fields, $webhookRegistrar);
|
||||
|
||||
global $wpdb;
|
||||
$cacheFactory = new CachePoolFactory($wpdb);
|
||||
$pool = $cacheFactory->createCachePool('ppcp-token');
|
||||
return new SettingsListener($settings, $fields, $webhookRegistrar, $pool);
|
||||
},
|
||||
'wcgateway.order-processor' => static function (ContainerInterface $container): OrderProcessor {
|
||||
|
||||
|
|
|
@ -4,8 +4,10 @@ declare(strict_types=1);
|
|||
|
||||
namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
|
||||
|
||||
use Inpsyde\PayPalCommerce\ApiClient\Authentication\PayPalBearer;
|
||||
use Inpsyde\PayPalCommerce\Onboarding\State;
|
||||
use Inpsyde\PayPalCommerce\Webhooks\WebhookRegistrar;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
class SettingsListener
|
||||
{
|
||||
|
@ -14,14 +16,17 @@ class SettingsListener
|
|||
private $settings;
|
||||
private $settingFields;
|
||||
private $webhookRegistrar;
|
||||
private $cache;
|
||||
public function __construct(
|
||||
Settings $settings,
|
||||
array $settingFields,
|
||||
WebhookRegistrar $webhookRegistrar
|
||||
WebhookRegistrar $webhookRegistrar,
|
||||
CacheInterface $cache
|
||||
) {
|
||||
$this->settings = $settings;
|
||||
$this->settingFields = $settingFields;
|
||||
$this->webhookRegistrar = $webhookRegistrar;
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
public function listen()
|
||||
|
@ -39,6 +44,7 @@ class SettingsListener
|
|||
$this->settings->reset();
|
||||
$this->settings->persist();
|
||||
$this->webhookRegistrar->unregister();
|
||||
$this->cache->delete(PayPalBearer::CACHE_KEY);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -54,6 +60,7 @@ class SettingsListener
|
|||
$this->settings->set($id, $value);
|
||||
}
|
||||
$this->settings->persist();
|
||||
$this->cache->delete(PayPalBearer::CACHE_KEY);
|
||||
}
|
||||
|
||||
//phpcs:disable Inpsyde.CodeQuality.NestingLevel.MaxExceeded
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue