|
12 | 12 | use WooCommerce\PayPalCommerce\Assets\AssetGetter; |
13 | 13 | use WooCommerce\PayPalCommerce\Assets\AssetGetterFactory; |
14 | 14 | use WooCommerce\PayPalCommerce\Compat\Assets\CompatAssets; |
15 | | -use WooCommerce\PayPalCommerce\Compat\Settings\GeneralSettingsMapHelper; |
16 | | -use WooCommerce\PayPalCommerce\Compat\Settings\PaymentMethodSettingsMapHelper; |
17 | | -use WooCommerce\PayPalCommerce\Compat\Settings\SettingsMap; |
18 | | -use WooCommerce\PayPalCommerce\Compat\Settings\SettingsMapHelper; |
19 | | -use WooCommerce\PayPalCommerce\Compat\Settings\SettingsTabMapHelper; |
20 | | -use WooCommerce\PayPalCommerce\Compat\Settings\StylingSettingsMapHelper; |
21 | | -use WooCommerce\PayPalCommerce\Compat\Settings\SubscriptionSettingsMapHelper; |
22 | 15 | use WooCommerce\PayPalCommerce\Compat\WooCommerceBlueprint\PayPalBlueprintBootstrap; |
23 | 16 | use WooCommerce\PayPalCommerce\Compat\WooCommerceBlueprint\PayPalSettingsExporter; |
24 | 17 | use WooCommerce\PayPalCommerce\Compat\WooCommerceBlueprint\PayPalSettingsImporter; |
|
126 | 119 | ); |
127 | 120 | }, |
128 | 121 |
|
129 | | - /** |
130 | | - * Configuration for the new/old settings map. |
131 | | - * |
132 | | - * @returns SettingsMap[] |
133 | | - */ |
134 | | - 'compat.setting.new-to-old-map' => static function ( ContainerInterface $container ): array { |
135 | | - $are_new_settings_enabled = $container->get( 'wcgateway.settings.admin-settings-enabled' ); |
136 | | - if ( ! $are_new_settings_enabled ) { |
137 | | - return array(); |
138 | | - } |
139 | | - |
140 | | - $styling_settings_map_helper = $container->get( 'compat.settings.styling_map_helper' ); |
141 | | - assert( $styling_settings_map_helper instanceof StylingSettingsMapHelper ); |
142 | | - |
143 | | - $settings_tab_map_helper = $container->get( 'compat.settings.settings_tab_map_helper' ); |
144 | | - assert( $settings_tab_map_helper instanceof SettingsTabMapHelper ); |
145 | | - |
146 | | - $subscription_map_helper = $container->get( 'compat.settings.subscription_map_helper' ); |
147 | | - assert( $subscription_map_helper instanceof SubscriptionSettingsMapHelper ); |
148 | | - |
149 | | - $general_map_helper = $container->get( 'compat.settings.general_map_helper' ); |
150 | | - assert( $general_map_helper instanceof GeneralSettingsMapHelper ); |
151 | | - |
152 | | - $payment_methods_map_helper = $container->get( 'compat.settings.payment_methods_map_helper' ); |
153 | | - assert( $payment_methods_map_helper instanceof PaymentMethodSettingsMapHelper ); |
154 | | - |
155 | | - return array( |
156 | | - new SettingsMap( |
157 | | - $container->get( 'settings.data.general' ), |
158 | | - $general_map_helper->map() |
159 | | - ), |
160 | | - new SettingsMap( |
161 | | - $container->get( 'settings.data.settings' ), |
162 | | - $settings_tab_map_helper->map() |
163 | | - ), |
164 | | - new SettingsMap( |
165 | | - $container->get( 'settings.data.styling' ), |
166 | | - /** |
167 | | - * The `StylingSettings` class stores settings as `LocationStylingDTO` objects. |
168 | | - * This method creates a mapping from old setting keys to the corresponding style names. |
169 | | - * |
170 | | - * Example: |
171 | | - * 'button_product_layout' => 'layout' |
172 | | - * |
173 | | - * This mapping will allow to retrieve the correct style value |
174 | | - * from a `LocationStylingDTO` object by dynamically accessing its properties. |
175 | | - */ |
176 | | - $styling_settings_map_helper->map() |
177 | | - ), |
178 | | - new SettingsMap( |
179 | | - $container->get( 'settings.data.settings' ), |
180 | | - $subscription_map_helper->map() |
181 | | - ), |
182 | | - /** |
183 | | - * We need to pass the PaymentSettings model instance to use it in some helpers. |
184 | | - * Once the new settings module is permanently enabled, |
185 | | - * this model can be passed as a dependency to the appropriate helper classes. |
186 | | - * For now, we must pass it this way to avoid errors when the new settings module is disabled. |
187 | | - */ |
188 | | - new SettingsMap( |
189 | | - $container->get( 'settings.data.payment' ), |
190 | | - array() |
191 | | - ), |
192 | | - new SettingsMap( |
193 | | - $container->get( 'settings.data.payment' ), |
194 | | - $payment_methods_map_helper->map() |
195 | | - ), |
196 | | - ); |
197 | | - }, |
198 | | - 'compat.settings.settings_map_helper' => static function ( ContainerInterface $container ): SettingsMapHelper { |
199 | | - return new SettingsMapHelper( |
200 | | - $container->get( 'compat.setting.new-to-old-map' ), |
201 | | - $container->get( 'compat.settings.styling_map_helper' ), |
202 | | - $container->get( 'compat.settings.settings_tab_map_helper' ), |
203 | | - $container->get( 'compat.settings.subscription_map_helper' ), |
204 | | - $container->get( 'compat.settings.general_map_helper' ), |
205 | | - $container->get( 'compat.settings.payment_methods_map_helper' ), |
206 | | - $container->get( 'wcgateway.settings.admin-settings-enabled' ) |
207 | | - ); |
208 | | - }, |
209 | | - 'compat.settings.styling_map_helper' => static function ( ContainerInterface $container ): StylingSettingsMapHelper { |
210 | | - $context_provider = static function () use ( $container ): string { |
211 | | - $context = $container->get( 'button.helper.context' ); |
212 | | - |
213 | | - return $context->context(); |
214 | | - }; |
215 | | - return new StylingSettingsMapHelper( $context_provider ); |
216 | | - }, |
217 | | - 'compat.settings.settings_tab_map_helper' => static function (): SettingsTabMapHelper { |
218 | | - return new SettingsTabMapHelper(); |
219 | | - }, |
220 | | - 'compat.settings.subscription_map_helper' => static function ( ContainerInterface $container ): SubscriptionSettingsMapHelper { |
221 | | - return new SubscriptionSettingsMapHelper( $container->get( 'wc-subscriptions.helper' ) ); |
222 | | - }, |
223 | | - 'compat.settings.general_map_helper' => static function (): GeneralSettingsMapHelper { |
224 | | - return new GeneralSettingsMapHelper(); |
225 | | - }, |
226 | | - 'compat.settings.payment_methods_map_helper' => static function (): PaymentMethodSettingsMapHelper { |
227 | | - return new PaymentMethodSettingsMapHelper(); |
228 | | - }, |
229 | 122 | 'compat.blueprint.is_available' => function (): bool { |
230 | 123 | return interface_exists( 'Automattic\WooCommerce\Blueprint\Exporters\StepExporter' ); |
231 | 124 | }, |
|
0 commit comments