🚧 Migrate button initialization to new workflow

The ContextHandlerFactory previously was used inside the ApplePayButton constructor.
This commit is contained in:
Philipp Stracker 2024-10-07 12:13:46 +02:00
parent 4604e68b5a
commit d5e406a563
No known key found for this signature in database

View file

@ -2,6 +2,7 @@
import buttonModuleWatcher from '../../../ppcp-button/resources/js/modules/ButtonModuleWatcher'; import buttonModuleWatcher from '../../../ppcp-button/resources/js/modules/ButtonModuleWatcher';
import ApplePayButton from './ApplepayButton'; import ApplePayButton from './ApplepayButton';
import ContextHandlerFactory from './Context/ContextHandlerFactory';
class ApplePayManager { class ApplePayManager {
constructor( buttonConfig, ppcpConfig ) { constructor( buttonConfig, ppcpConfig ) {
@ -11,11 +12,19 @@ class ApplePayManager {
this.buttons = []; this.buttons = [];
buttonModuleWatcher.watchContextBootstrap( ( bootstrap ) => { buttonModuleWatcher.watchContextBootstrap( ( bootstrap ) => {
const button = new ApplePayButton( this.contextHandler = ContextHandlerFactory.create(
bootstrap.context,
buttonConfig,
ppcpConfig,
bootstrap.handler
);
const button = ApplePayButton.createButton(
bootstrap.context, bootstrap.context,
bootstrap.handler, bootstrap.handler,
buttonConfig, buttonConfig,
ppcpConfig ppcpConfig,
this.contextHandler
); );
this.buttons.push( button ); this.buttons.push( button );