Refactor default settings to match new settings

This commit is contained in:
Narek Zakarian 2022-12-05 17:12:30 +04:00
parent 7f120720cc
commit 2205b1bc1e
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7
2 changed files with 12 additions and 15 deletions

View file

@ -142,7 +142,7 @@ return array(
'wcgateway.disabler' => static function ( ContainerInterface $container ): DisableGateways {
$session_handler = $container->get( 'session.handler' );
$settings = $container->get( 'wcgateway.settings' );
$settings_status = $container->get( 'wcgateway.settings.status' );
$settings_status = $container->get( 'wcgateway.settings.status' );
return new DisableGateways( $session_handler, $settings, $settings_status );
},
@ -195,8 +195,8 @@ return array(
},
'wcgateway.settings' => static function ( ContainerInterface $container ): Settings {
$messaging_locations = $container->get( 'wcgateway.settings.pay-later.messaging-locations' );
return new Settings( array_keys( $messaging_locations ) );
$default_button_locations = $container->get( 'wcgateway.button.default-locations' );
return new Settings( $default_button_locations );
},
'wcgateway.notice.connect' => static function ( ContainerInterface $container ): ConnectAdminNotice {
$state = $container->get( 'onboarding.state' );
@ -1283,6 +1283,6 @@ return array(
$settings = $container->get( 'wcgateway.settings' );
assert( $settings instanceof Settings );
return $this->settings->has( 'smart_button_locations' ) ? $this->settings->get( 'smart_button_locations' ) : array();
return $settings->has( 'smart_button_locations' ) ? $settings->get( 'smart_button_locations' ) : array();
},
);

View file

@ -29,19 +29,19 @@ class Settings implements ContainerInterface {
private $settings = array();
/**
* The list of pay later selected default locations.
* The list of selected default button locations.
*
* @var string[]
*/
protected $pay_later_default_locations;
protected $default_button_locations;
/**
* Settings constructor.
*
* @param string[] $pay_later_default_locations The list of pay later selected default locations.
* @param string[] $default_button_locations The list of selected default button locations.
*/
public function __construct( array $pay_later_default_locations ) {
$this->pay_later_default_locations = $pay_later_default_locations;
public function __construct( array $default_button_locations ) {
$this->default_button_locations = $default_button_locations;
}
/**
@ -109,14 +109,11 @@ class Settings implements ContainerInterface {
'Pay via PayPal.',
'woocommerce-paypal-payments'
),
'button_product_enabled' => true,
'button_mini-cart_enabled' => false,
'button_cart_enabled' => true,
'smart_button_locations' => $this->default_button_locations,
'pay_later_messaging_enabled' => true,
'button_enabled' => true,
'pay_later_button_enabled' => true,
'pay_later_button_locations' => $this->pay_later_default_locations,
'pay_later_messaging_locations' => $this->pay_later_default_locations,
'pay_later_button_locations' => $this->default_button_locations,
'pay_later_messaging_locations' => $this->default_button_locations,
'brand_name' => get_bloginfo( 'name' ),
'dcc_gateway_title' => __( 'Credit Cards', 'woocommerce-paypal-payments' ),
'dcc_gateway_description' => __(