woocommerce-paypal-payments/modules/ppcp-googlepay/src/GooglepayModule.php

78 lines
1.6 KiB
PHP
Raw Normal View History

2023-08-22 08:44:32 +01:00
<?php
/**
* The Googlepay module.
*
* @package WooCommerce\PayPalCommerce\Googlepay
*/
declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Googlepay;
use WooCommerce\PayPalCommerce\Button\Assets\SmartButtonInterface;
use WooCommerce\PayPalCommerce\Googlepay\Assets\ButtonInterface;
use WooCommerce\PayPalCommerce\Onboarding\Environment;
use WooCommerce\PayPalCommerce\Vendor\Dhii\Container\ServiceProvider;
use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface;
use WooCommerce\PayPalCommerce\Vendor\Interop\Container\ServiceProviderInterface;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
/**
* Class GooglepayModule
*/
class GooglepayModule implements ModuleInterface {
/**
* {@inheritDoc}
*/
public function setup(): ServiceProviderInterface {
return new ServiceProvider(
require __DIR__ . '/../services.php',
require __DIR__ . '/../extensions.php'
);
}
/**
* {@inheritDoc}
*/
public function run( ContainerInterface $c ): void {
add_action(
'wp',
static function () use ( $c ) {
if ( is_admin() ) {
return;
}
$button = $c->get( 'googlepay.button' );
/**
* The Button.
*
* @var ButtonInterface $button
*/
$button->render_buttons();
}
);
add_action(
'wp_enqueue_scripts',
static function () use ( $c ) {
$button = $c->get( 'googlepay.button' );
assert( $button instanceof ButtonInterface );
if ( $button->should_load_script() ) {
$button->enqueue();
}
}
);
}
/**
* Returns the key for the module.
*
* @return string|void
*/
public function getKey() {
}
}