mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Do not cache webhook.status.registered-webhooks
This commit is contained in:
parent
f51dbfc6d3
commit
dd82f67888
3 changed files with 37 additions and 13 deletions
28
modules/ppcp-webhooks/factories.php
Normal file
28
modules/ppcp-webhooks/factories.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* The webhook module factories.
|
||||
*
|
||||
* @package WooCommerce\PayPalCommerce\Webhooks
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WooCommerce\PayPalCommerce\Webhooks;
|
||||
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\WebhookEndpoint;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\State;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
||||
|
||||
return array(
|
||||
'webhook.status.registered-webhooks' => function( ContainerInterface $container ) : array {
|
||||
$endpoint = $container->get( 'api.endpoint.webhook' );
|
||||
assert( $endpoint instanceof WebhookEndpoint );
|
||||
|
||||
$state = $container->get( 'onboarding.state' );
|
||||
if ( $state->current_state() >= State::STATE_ONBOARDED ) {
|
||||
return $endpoint->list();
|
||||
}
|
||||
|
||||
return array();
|
||||
},
|
||||
);
|
|
@ -131,18 +131,6 @@ return array(
|
|||
return $container->get( 'webhook.current' ) !== null;
|
||||
},
|
||||
|
||||
'webhook.status.registered-webhooks' => function( ContainerInterface $container ) : array {
|
||||
$endpoint = $container->get( 'api.endpoint.webhook' );
|
||||
assert( $endpoint instanceof WebhookEndpoint );
|
||||
|
||||
$state = $container->get( 'onboarding.state' );
|
||||
if ( $state->current_state() >= State::STATE_ONBOARDED ) {
|
||||
return $endpoint->list();
|
||||
}
|
||||
|
||||
return array();
|
||||
},
|
||||
|
||||
'webhook.status.registered-webhooks-data' => function( ContainerInterface $container ) : array {
|
||||
$empty_placeholder = __( 'No webhooks found.', 'woocommerce-paypal-payments' );
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ use WooCommerce\PayPalCommerce\Onboarding\State;
|
|||
use Exception;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExtendingModule;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\FactoryModule;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
||||
|
@ -27,7 +28,7 @@ use WooCommerce\PayPalCommerce\Webhooks\Status\Assets\WebhooksStatusPageAssets;
|
|||
/**
|
||||
* Class WebhookModule
|
||||
*/
|
||||
class WebhookModule implements ServiceModule, ExtendingModule, ExecutableModule {
|
||||
class WebhookModule implements ServiceModule, FactoryModule, ExtendingModule, ExecutableModule {
|
||||
use ModuleClassNameIdTrait;
|
||||
|
||||
/**
|
||||
|
@ -37,6 +38,13 @@ class WebhookModule implements ServiceModule, ExtendingModule, ExecutableModule
|
|||
return require __DIR__ . '/../services.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function factories(): array {
|
||||
return require __DIR__ . '/../factories.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue