Fix name to avoid confusion

This commit is contained in:
Alex P 2023-03-08 17:36:38 +02:00
parent 91c39fdef2
commit c77f20d2f9
No known key found for this signature in database
GPG key ID: 54487A734A204D71
5 changed files with 32 additions and 32 deletions

View file

@ -20,7 +20,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
use WooCommerce\PayPalCommerce\Button\Helper\MessagesApply;
use WooCommerce\PayPalCommerce\Compat\PPEC\PPECHelper;
use WooCommerce\PayPalCommerce\Onboarding\State;
use WooCommerce\PayPalCommerce\Webhooks\WebhookInfoStorage;
use WooCommerce\PayPalCommerce\Webhooks\WebhookEventStorage;
/**
* Class StatusReportModule
@ -62,7 +62,7 @@ class StatusReportModule implements ModuleInterface {
$messages_apply = $c->get( 'button.helper.messages-apply' );
$last_webhook_storage = $c->get( 'webhook.last-webhook-storage' );
assert( $last_webhook_storage instanceof WebhookInfoStorage );
assert( $last_webhook_storage instanceof WebhookEventStorage );
$billing_agreements_endpoint = $c->get( 'api.endpoint.billing-agreements' );
assert( $billing_agreements_endpoint instanceof BillingAgreementsEndpoint );

View file

@ -198,8 +198,8 @@ return array(
);
},
'webhook.last-webhook-storage' => static function ( ContainerInterface $container ): WebhookInfoStorage {
return new WebhookInfoStorage( $container->get( 'webhook.last-webhook-storage.key' ) );
'webhook.last-webhook-storage' => static function ( ContainerInterface $container ): WebhookEventStorage {
return new WebhookEventStorage( $container->get( 'webhook.last-webhook-storage.key' ) );
},
'webhook.last-webhook-storage.key' => static function ( ContainerInterface $container ): string {
return 'ppcp-last-webhook';

View file

@ -77,11 +77,11 @@ class IncomingWebhookEndpoint {
private $simulation;
/**
* The last webhook info storage.
* The last webhook event storage.
*
* @var WebhookInfoStorage
* @var WebhookEventStorage
*/
private $last_webhook_storage;
private $last_webhook_event_storage;
/**
* IncomingWebhookEndpoint constructor.
@ -92,7 +92,7 @@ class IncomingWebhookEndpoint {
* @param bool $verify_request Whether requests need to be verified or not.
* @param WebhookEventFactory $webhook_event_factory The webhook event factory.
* @param WebhookSimulation $simulation The simulation handler.
* @param WebhookInfoStorage $last_webhook_storage The last webhook info storage.
* @param WebhookEventStorage $last_webhook_event_storage The last webhook event storage.
* @param RequestHandler ...$handlers The handlers, which process a request in the end.
*/
public function __construct(
@ -102,18 +102,18 @@ class IncomingWebhookEndpoint {
bool $verify_request,
WebhookEventFactory $webhook_event_factory,
WebhookSimulation $simulation,
WebhookInfoStorage $last_webhook_storage,
WebhookEventStorage $last_webhook_event_storage,
RequestHandler ...$handlers
) {
$this->webhook_endpoint = $webhook_endpoint;
$this->webhook = $webhook;
$this->handlers = $handlers;
$this->logger = $logger;
$this->verify_request = $verify_request;
$this->webhook_event_factory = $webhook_event_factory;
$this->last_webhook_storage = $last_webhook_storage;
$this->simulation = $simulation;
$this->webhook_endpoint = $webhook_endpoint;
$this->webhook = $webhook;
$this->handlers = $handlers;
$this->logger = $logger;
$this->verify_request = $verify_request;
$this->webhook_event_factory = $webhook_event_factory;
$this->last_webhook_event_storage = $last_webhook_event_storage;
$this->simulation = $simulation;
}
/**
@ -186,7 +186,7 @@ class IncomingWebhookEndpoint {
public function handle_request( \WP_REST_Request $request ): \WP_REST_Response {
$event = $this->event_from_request( $request );
$this->last_webhook_storage->save( $event );
$this->last_webhook_event_storage->save( $event );
if ( $this->simulation->is_simulation_event( $event ) ) {
$this->logger->info( 'Received simulated webhook.' );

View file

@ -12,9 +12,9 @@ namespace WooCommerce\PayPalCommerce\Webhooks;
use WooCommerce\PayPalCommerce\ApiClient\Entity\WebhookEvent;
/**
* Class WebhookInfoStorage
* Class WebhookEventStorage
*/
class WebhookInfoStorage {
class WebhookEventStorage {
/**
* The WP option key.

View file

@ -45,11 +45,11 @@ class WebhookRegistrar {
private $rest_endpoint;
/**
* The last webhook info storage.
* The last webhook event storage.
*
* @var WebhookInfoStorage
* @var WebhookEventStorage
*/
private $last_webhook_storage;
private $last_webhook_event_storage;
/**
* The logger.
@ -64,22 +64,22 @@ class WebhookRegistrar {
* @param WebhookFactory $webhook_factory The Webhook factory.
* @param WebhookEndpoint $endpoint The Webhook endpoint.
* @param IncomingWebhookEndpoint $rest_endpoint The WordPress Rest API endpoint.
* @param WebhookInfoStorage $last_webhook_storage The last webhook info storage.
* @param WebhookEventStorage $last_webhook_event_storage The last webhook event storage.
* @param LoggerInterface $logger The logger.
*/
public function __construct(
WebhookFactory $webhook_factory,
WebhookEndpoint $endpoint,
IncomingWebhookEndpoint $rest_endpoint,
WebhookInfoStorage $last_webhook_storage,
WebhookEventStorage $last_webhook_event_storage,
LoggerInterface $logger
) {
$this->webhook_factory = $webhook_factory;
$this->endpoint = $endpoint;
$this->rest_endpoint = $rest_endpoint;
$this->last_webhook_storage = $last_webhook_storage;
$this->logger = $logger;
$this->webhook_factory = $webhook_factory;
$this->endpoint = $endpoint;
$this->rest_endpoint = $rest_endpoint;
$this->last_webhook_event_storage = $last_webhook_event_storage;
$this->logger = $logger;
}
/**
@ -102,7 +102,7 @@ class WebhookRegistrar {
self::KEY,
$created->to_array()
);
$this->last_webhook_storage->clear();
$this->last_webhook_event_storage->clear();
$this->logger->info( 'Webhooks subscribed.' );
return true;
} catch ( RuntimeException $error ) {
@ -131,7 +131,7 @@ class WebhookRegistrar {
if ( $success ) {
delete_option( self::KEY );
$this->last_webhook_storage->clear();
$this->last_webhook_event_storage->clear();
$this->logger->info( 'Webhooks deleted.' );
}
return $success;