Separate "module loaded" "block enabled" methods

This commit is contained in:
Narek Zakarian 2024-03-05 17:06:40 +04:00
parent 71c0da5c35
commit f2a741094c
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7

View file

@ -15,6 +15,7 @@ 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;
use WooCommerce\PayPalCommerce\WcGateway\Helper\SettingsStatus;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
/**
@ -22,16 +23,26 @@ use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
*/
class PayLaterBlockModule implements ModuleInterface {
/**
* Returns whether the block should be loaded.
* Returns whether the block module should be loaded.
*/
public static function is_enabled(): bool {
public static function is_module_loading_required(): bool {
return apply_filters(
// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
'woocommerce.feature-flags.woocommerce_paypal_payments.paylater_block_enabled',
getenv( 'PCP_PAYLATER_BLOCK' ) === '1'
getenv( 'PCP_PAYLATER_BLOCK' ) !== '0'
);
}
/**
* Returns whether the block is enabled.
*
* @param SettingsStatus $settings_status The Settings status helper.
* @return bool true if the block is enabled, otherwise false.
*/
public static function is_block_enabled( SettingsStatus $settings_status ): bool {
return self::is_module_loading_required() && $settings_status->is_pay_later_messaging_enabled_for_location( 'product_preview' );
}
/**
* {@inheritDoc}
*/