PluginProbe
seQura / 4.1.0
seQura v4.1.0
4.3.4 4.3.3 4.3.2 4.3.1 trunk 2.0.0 2.0.10 2.0.11 2.0.12 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 3.0.0 3.0.2 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 4.0.0 All 30 releases
← All changes | src/class-bootstrap.php +398 -304 3.0.54.1.0 View file →
@@ -6,10 +6,8 @@
6 6 */
7 7
8 8 namespace SeQura\WC;
9 9
10 -use SeQura\Core\BusinessLogic\AdminAPI\GeneralSettings\GeneralSettingsController;
11 -use SeQura\Core\BusinessLogic\AdminAPI\PromotionalWidgets\PromotionalWidgetsController;
12 10 use SeQura\Core\BusinessLogic\BootstrapComponent;
13 11 use SeQura\Core\BusinessLogic\DataAccess\ConnectionData\Entities\ConnectionData;
14 12 use SeQura\Core\BusinessLogic\DataAccess\OrderSettings\Entities\OrderStatusSettings;
15 13 use SeQura\Core\BusinessLogic\DataAccess\PromotionalWidgets\Entities\WidgetSettings;
@@ -16,33 +14,35 @@
16 14 use SeQura\Core\BusinessLogic\DataAccess\SendReport\Entities\SendReport;
17 15 use SeQura\Core\BusinessLogic\DataAccess\StatisticalData\Entities\StatisticalData;
18 16 use SeQura\Core\BusinessLogic\DataAccess\TransactionLog\Entities\TransactionLog;
19 17 use SeQura\Core\BusinessLogic\DataAccess\CountryConfiguration\Entities\CountryConfiguration;
18 +use SeQura\Core\BusinessLogic\DataAccess\Credentials\Entities\Credentials;
19 +use SeQura\Core\BusinessLogic\DataAccess\Deployments\Entities\Deployment;
20 20 use SeQura\Core\BusinessLogic\DataAccess\GeneralSettings\Entities\GeneralSettings;
21 +use SeQura\Core\BusinessLogic\DataAccess\PaymentMethod\Entities\PaymentMethod;
22 +use SeQura\Core\BusinessLogic\Domain\Connection\Services\ConnectionService;
23 +use SeQura\Core\BusinessLogic\Domain\Connection\Services\CredentialsService;
21 24 use SeQura\Core\BusinessLogic\Domain\CountryConfiguration\RepositoryContracts\CountryConfigurationRepositoryInterface;
22 -use SeQura\Core\BusinessLogic\Domain\GeneralSettings\RepositoryContracts\GeneralSettingsRepositoryInterface;
23 -use SeQura\Core\BusinessLogic\Domain\GeneralSettings\Services\CategoryService;
24 -use SeQura\Core\BusinessLogic\Domain\GeneralSettings\Services\GeneralSettingsService;
25 25 use SeQura\Core\BusinessLogic\Domain\Integration\Category\CategoryServiceInterface;
26 26 use SeQura\Core\BusinessLogic\Domain\Integration\Disconnect\DisconnectServiceInterface;
27 +use SeQura\Core\BusinessLogic\Domain\Integration\Order\MerchantDataProviderInterface;
28 +use SeQura\Core\BusinessLogic\Domain\Integration\Order\OrderCreationInterface;
27 29 use SeQura\Core\BusinessLogic\Domain\Integration\OrderReport\OrderReportServiceInterface;
30 +use SeQura\Core\BusinessLogic\Domain\Integration\Product\ProductServiceInterface;
28 31 use SeQura\Core\BusinessLogic\Domain\Integration\SellingCountries\SellingCountriesServiceInterface;
29 32 use SeQura\Core\BusinessLogic\Domain\Integration\ShopOrderStatuses\ShopOrderStatusesServiceInterface;
30 33 use SeQura\Core\BusinessLogic\Domain\Integration\Store\StoreServiceInterface;
31 34 use SeQura\Core\BusinessLogic\Domain\Integration\Version\VersionServiceInterface;
32 35 use SeQura\Core\BusinessLogic\Domain\Multistore\StoreContext;
33 -use SeQura\Core\BusinessLogic\Domain\Order\Models\OrderRequest\Item\AbstractItemFactory;
34 36 use SeQura\Core\BusinessLogic\Domain\Order\Models\SeQuraOrder;
35 37 use SeQura\Core\BusinessLogic\Domain\Order\RepositoryContracts\SeQuraOrderRepositoryInterface;
36 38 use SeQura\Core\BusinessLogic\Domain\OrderStatusSettings\RepositoryContracts\OrderStatusSettingsRepositoryInterface;
37 39 use SeQura\Core\BusinessLogic\Domain\OrderStatusSettings\Services\OrderStatusSettingsService;
38 -use SeQura\Core\BusinessLogic\Domain\PromotionalWidgets\RepositoryContracts\WidgetSettingsRepositoryInterface;
39 -use SeQura\Core\BusinessLogic\Domain\PromotionalWidgets\Services\WidgetSettingsService;
40 40 use SeQura\Core\BusinessLogic\Domain\StatisticalData\RepositoryContracts\StatisticalDataRepositoryInterface;
41 -use SeQura\Core\BusinessLogic\Domain\Stores\Services\StoreService;
42 41 use SeQura\Core\BusinessLogic\Utility\EncryptorInterface;
43 42 use SeQura\Core\BusinessLogic\Webhook\Services\ShopOrderService;
44 43 use SeQura\Core\Infrastructure\Configuration\ConfigEntity;
44 +use SeQura\Core\Infrastructure\Exceptions\ServiceNotRegisteredException;
45 45 use SeQura\Core\Infrastructure\Logger\Interfaces\DefaultLoggerAdapter;
46 46 use SeQura\Core\Infrastructure\Logger\Interfaces\ShopLoggerAdapter;
47 47 use SeQura\Core\Infrastructure\Logger\LoggerConfiguration;
48 48 use SeQura\Core\Infrastructure\ORM\RepositoryRegistry;
@@ -69,12 +69,10 @@
69 69 use SeQura\WC\Controllers\Rest\General_Settings_REST_Controller;
70 70 use SeQura\WC\Controllers\Rest\Log_REST_Controller;
71 71 use SeQura\WC\Controllers\Rest\Onboarding_REST_Controller;
72 72 use SeQura\WC\Controllers\Rest\Payment_REST_Controller;
73 -use SeQura\WC\Core\BusinessLogic\Domain\Order\Models\OrderRequest\Item\Item_Factory;
74 73 use SeQura\WC\Core\Extension\BusinessLogic\Domain\Order\Builders\Interface_Create_Order_Request_Builder;
75 74 use SeQura\WC\Core\Extension\BusinessLogic\Domain\OrderStatusSettings\Services\Order_Status_Settings_Service;
76 -use SeQura\WC\Core\Extension\Infrastructure\Configuration\Configuration;
77 75 use SeQura\WC\Core\Implementation\BusinessLogic\Domain\Integration\Category\Category_Service;
78 76 use SeQura\WC\Core\Implementation\BusinessLogic\Domain\Integration\Disconnect\Disconnect_Service;
79 77 use SeQura\WC\Core\Implementation\BusinessLogic\Domain\Integration\ShopOrderStatuses\Shop_Order_Status_Service;
80 78 use SeQura\WC\Core\Implementation\BusinessLogic\Domain\Order\Builders\Create_Order_Request_Builder;
@@ -81,21 +79,18 @@
81 79 use SeQura\WC\Core\Implementation\BusinessLogic\Utility\Encryptor;
82 80 use SeQura\WC\Core\Implementation\BusinessLogic\Webhook\Services\Shop_Order_Service;
83 81 use SeQura\WC\Core\Implementation\Infrastructure\Logger\Interfaces\Default_Logger_Adapter;
84 82 use SeQura\WC\Core\Implementation\Infrastructure\Logger\Interfaces\Shop_Logger_Adapter;
85 -use SeQura\WC\Core\Extension\BusinessLogic\AdminAPI\GeneralSettings\General_Settings_Controller;
86 -use SeQura\WC\Core\Extension\BusinessLogic\AdminAPI\PromotionalWidgets\Promotional_Widgets_Controller;
87 -use SeQura\WC\Core\Extension\BusinessLogic\DataAccess\GeneralSettings\Repositories\General_Settings_Repository;
88 -use SeQura\WC\Core\Extension\BusinessLogic\DataAccess\PromotionalWidgets\Repositories\Widget_Settings_Repository;
89 83 use SeQura\WC\Core\Implementation\BusinessLogic\Domain\Integration\OrderReport\Order_Report_Service;
90 84 use SeQura\WC\Repositories\Entity_Repository;
91 85 use SeQura\WC\Repositories\Migrations\Migration_Install_300;
86 +use SeQura\WC\Repositories\Migrations\Migration_Install_320;
92 87 use SeQura\WC\Repositories\Queue_Item_Repository;
88 +use SeQura\WC\Repositories\Repository;
93 89 use SeQura\WC\Repositories\SeQura_Order_Repository;
94 -use SeQura\WC\Services\Assets\Assets;
95 -use SeQura\WC\Services\Assets\Interface_Assets;
96 90 use SeQura\WC\Services\Cart\Cart_Service;
97 91 use SeQura\WC\Services\Cart\Interface_Cart_Service;
92 +use SeQura\WC\Services\Constants\Constants;
98 93 use SeQura\WC\Services\Core\Selling_Countries_Service;
99 94 use SeQura\WC\Services\Core\Store_Service;
100 95 use SeQura\WC\Services\Core\Version_Service;
101 96 use SeQura\WC\Services\Shopper\Shopper_Service;
@@ -101,29 +96,57 @@
101 96 use SeQura\WC\Services\Shopper\Shopper_Service;
102 97 use SeQura\WC\Services\Shopper\Interface_Shopper_Service;
103 98 use SeQura\WC\Services\I18n\I18n;
104 99 use SeQura\WC\Services\I18n\Interface_I18n;
105 -use SeQura\WC\Services\Interface_Log_File;
106 -use SeQura\WC\Services\Interface_Logger_Service;
107 -use SeQura\WC\Services\Log_File;
108 -use SeQura\WC\Services\Logger_Service;
100 +use SeQura\WC\Services\Log\Interface_Log_File;
101 +use SeQura\WC\Services\Log\Interface_Logger_Service;
102 +use SeQura\WC\Services\Log\Log_File;
103 +use SeQura\WC\Services\Log\Logger_Service;
109 104 use SeQura\WC\Services\Migration\Interface_Migration_Manager;
110 105 use SeQura\WC\Services\Migration\Migration_Manager;
111 106 use SeQura\WC\Services\Order\Interface_Order_Service;
112 107 use SeQura\WC\Services\Order\Order_Service;
113 108 use SeQura\WC\Services\Payment\Interface_Payment_Method_Service;
114 -use SeQura\WC\Services\Payment\Interface_Payment_Service;
115 109 use SeQura\WC\Services\Payment\Payment_Method_Service;
116 -use SeQura\WC\Services\Payment\Payment_Service;
117 110 use SeQura\WC\Services\Payment\Sequra_Payment_Gateway_Block_Support;
118 111 use SeQura\WC\Services\Pricing\Interface_Pricing_Service;
119 112 use SeQura\WC\Services\Pricing\Pricing_Service;
120 113 use SeQura\WC\Services\Product\Interface_Product_Service;
121 114 use SeQura\WC\Services\Product\Product_Service;
122 -use SeQura\WC\Services\Regex\Interface_Regex;
123 -use SeQura\WC\Services\Regex\Regex;
124 115 use SeQura\WC\Services\Report\Interface_Report_Service;
125 116 use SeQura\WC\Services\Report\Report_Service;
117 +use SeQura\WC\Services\Constants\Interface_Constants;
118 +use SeQura\WC\Services\Time\Interface_Time_Checker_Service;
119 +use SeQura\WC\Services\Time\Time_Checker_Service;
120 +use SeQura\Core\BusinessLogic\Domain\Integration\PromotionalWidgets\WidgetConfiguratorInterface;
121 +use SeQura\Core\BusinessLogic\Domain\Integration\PromotionalWidgets\MiniWidgetMessagesProviderInterface;
122 +use SeQura\Core\BusinessLogic\Domain\Order\Builders\MerchantOrderRequestBuilder;
123 +use SeQura\Core\BusinessLogic\Domain\Order\Service\OrderService;
124 +use SeQura\Core\Infrastructure\Configuration\Configuration;
125 +use SeQura\Core\Infrastructure\Utility\RegexProvider;
126 +use SeQura\WC\Core\Implementation\BusinessLogic\Domain\Integration\Order\Merchant_Data_Provider;
127 +use SeQura\WC\Core\Implementation\BusinessLogic\Domain\Integration\Order\Order_Creation;
128 +use SeQura\WC\Core\Implementation\BusinessLogic\Domain\Integration\Product\Product_Service as Core_Product_Service;
129 +use SeQura\WC\Core\Implementation\BusinessLogic\Domain\Integration\PromotionalWidgets\Mini_Widget_Messages_Provider;
130 +use SeQura\WC\Core\Implementation\BusinessLogic\Domain\Integration\PromotionalWidgets\Widget_Configurator;
131 +use SeQura\WC\Repositories\Migrations\Migration_Install_400;
132 +use SeQura\WC\Services\Order\Current_Order_Provider;
133 +use SeQura\WC\Services\Order\Interface_Current_Order_Provider;
134 +use SeQura\WC\Services\Platform\Interface_Platform_Provider;
135 +use SeQura\WC\Services\Platform\Platform_Provider;
136 +use SeQura\WC\Services\Widgets\Interface_Widgets_Service;
137 +use SeQura\WC\Services\Widgets\Widgets_Service;
138 +use SeQura\Core\BusinessLogic\Domain\Integration\Store\StoreIdProvider;
139 +use SeQura\Core\Infrastructure\Configuration\ConfigurationManager;
140 +use SeQura\WC\Core\Extension\BusinessLogic\Domain\Integration\Store\Store_Id_Provider;
141 +use SeQura\WC\Services\Order\Builder\Interface_Order_Address_Builder;
142 +use SeQura\WC\Services\Order\Builder\Order_Address_Builder;
143 +use SeQura\WC\Services\Order\Builder\Interface_Order_Customer_Builder;
144 +use SeQura\WC\Services\Order\Builder\Interface_Order_Delivery_Method_Builder;
145 +use SeQura\WC\Services\Order\Builder\Order_Customer_Builder;
146 +use SeQura\WC\Services\Order\Builder\Order_Delivery_Method_Builder;
147 +use SeQura\WC\Services\Service\Interface_Settings_Service;
148 +use SeQura\WC\Services\Service\Settings_Service;
126 149
127 150 /**
128 151 * Implementation for the core bootstrap class.
129 152 */
@@ -128,8 +151,9 @@
128 151 * Implementation for the core bootstrap class.
129 152 */
130 153 class Bootstrap extends BootstrapComponent {
131 154
155 +
132 156 /**
133 157 * Cache for Service instances.
134 158 *
135 159 * @var array<string, mixed>
@@ -145,17 +169,10 @@
145 169
146 170 Reg::registerService(
147 171 Plugin::class,
148 172 static function () {
149 - $env_data = (array) Reg::getService( 'environment.data' );
150 - $wc_data = (array) Reg::getService( 'woocommerce.data' );
151 -
152 173 return new Plugin(
153 - Reg::getService( 'plugin.data' ),
154 - $env_data['wp_version'] ?? '',
155 - $wc_data['Version'] ?? '',
156 - Reg::getService( 'plugin.file_path' ),
157 - Reg::getService( 'plugin.basename' ),
174 + Reg::getService( Interface_Constants::class ),
158 175 Reg::getService( Interface_Migration_Manager::class ),
159 176 Reg::getService( Interface_I18n_Controller::class ),
160 177 Reg::getService( Interface_Assets_Controller::class ),
161 178 Reg::getService( Interface_Settings_Controller::class ),
@@ -176,105 +193,28 @@
176 193 * Initializes constants.
177 194 */
178 195 public static function initConstants(): void {
179 196 Reg::registerService(
180 - 'plugin.dir_path',
197 + Interface_Constants::class,
181 198 static function () {
182 - if ( ! isset( self::$cache['plugin.dir_path'] ) ) {
183 - self::$cache['plugin.dir_path'] = trailingslashit( dirname( __DIR__, 1 ) );
184 - }
185 - return self::$cache['plugin.dir_path'];
186 - }
187 - );
188 - Reg::registerService(
189 - 'plugin.file_path',
190 - static function () {
191 - if ( ! isset( self::$cache['plugin.file_path'] ) ) {
192 - self::$cache['plugin.file_path'] = Reg::getService( 'plugin.dir_path' ) . 'sequra.php';
193 - }
194 - return self::$cache['plugin.file_path'];
195 - }
196 - );
197 - Reg::registerService(
198 - 'plugin.log_file_path',
199 - static function () {
200 - if ( ! isset( self::$cache['plugin.log_file_path'] ) ) {
201 - self::$cache['plugin.log_file_path'] = Reg::getService( 'plugin.dir_path' ) . 'sequra.{storeId}.log';
202 - }
203 - return self::$cache['plugin.log_file_path'];
204 - }
205 - );
206 199
207 - Reg::registerService(
208 - 'plugin.basename',
209 - static function () {
210 - if ( ! isset( self::$cache['plugin.basename'] ) ) {
211 - self::$cache['plugin.basename'] = plugin_basename( Reg::getService( 'plugin.dir_path' ) . 'sequra.php' );
212 - }
213 - return self::$cache['plugin.basename'];
214 - }
215 - );
200 + if ( ! isset( self::$cache[ Interface_Constants::class ] ) ) {
201 + $dir_path = \trailingslashit( dirname( __DIR__, 1 ) );
202 + $plugin_file_path = $dir_path . 'sequra.php';
216 203
217 - Reg::registerService(
218 - 'plugin.dir_url',
219 - static function () {
220 - if ( ! isset( self::$cache['plugin.dir_url'] ) ) {
221 - self::$cache['plugin.dir_url'] = plugin_dir_url( Reg::getService( 'plugin.file_path' ) );
222 - }
223 - return self::$cache['plugin.dir_url'];
224 - }
225 - );
226 -
227 - Reg::registerService(
228 - 'plugin.rest_namespace',
229 - static function () {
230 - if ( ! isset( self::$cache['plugin.rest_namespace'] ) ) {
231 - self::$cache['plugin.rest_namespace'] = 'sequra/v1';
232 - }
233 - return self::$cache['plugin.rest_namespace'];
234 - }
235 - );
236 -
237 - Reg::registerService(
238 - 'woocommerce.data',
239 - static function () {
240 - if ( ! isset( self::$cache['woocommerce.data'] ) ) {
241 204 if ( ! function_exists( 'get_plugin_data' ) ) {
242 205 require_once ABSPATH . 'wp-admin/includes/plugin.php';
243 206 }
244 - self::$cache['woocommerce.data'] = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php' );
245 - }
246 - return self::$cache['woocommerce.data'];
247 - }
248 - );
249 -
250 - Reg::registerService(
251 - 'plugin.data',
252 - static function () {
253 - if ( ! isset( self::$cache['plugin.data'] ) ) {
254 - if ( ! function_exists( 'get_plugin_data' ) ) {
255 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
256 - }
257 207 $add_wc_headers = function ( $headers ) {
258 208 $headers['WC requires at least'] = 'WC requires at least';
259 209 return $headers;
260 210 };
261 - add_filter( 'extra_plugin_headers', $add_wc_headers );
262 - $data = get_plugin_data( Reg::getService( 'plugin.file_path' ) );
263 - remove_filter( 'extra_plugin_headers', $add_wc_headers );
211 + \add_filter( 'extra_plugin_headers', $add_wc_headers );
212 + $data = \get_plugin_data( $plugin_file_path, true, false );
213 + \remove_filter( 'extra_plugin_headers', $add_wc_headers );
264 214 $data['RequiresWC'] = $data['WC requires at least'];
265 215 unset( $data['WC requires at least'] );
266 216
267 - self::$cache['plugin.data'] = $data;
268 - }
269 - return self::$cache['plugin.data'];
270 - }
271 - );
272 -
273 - Reg::registerService(
274 - 'environment.data',
275 - static function () {
276 - if ( ! isset( self::$cache['environment.data'] ) ) {
277 217 /**
278 218 * Database instance.
279 219 *
280 220 * @var \wpdb $wpdb
@@ -280,10 +220,10 @@
280 220 * @var \wpdb $wpdb
281 221 */
282 222 $wpdb = Reg::getService( \wpdb::class );
283 223 global $wp_version;
284 -
285 - self::$cache['environment.data'] = array(
224 +
225 + $environment_data = array(
286 226 'php_version' => phpversion(),
287 227 'php_os' => PHP_OS,
288 228 'uname' => php_uname(),
289 229 'db_name' => false === strpos( strtolower( $wpdb->db_server_info() ), 'mariadb' ) ? 'mysql' : 'mariadb',
@@ -289,40 +229,40 @@
289 229 'db_name' => false === strpos( strtolower( $wpdb->db_server_info() ), 'mariadb' ) ? 'mysql' : 'mariadb',
290 230 'db_version' => $wpdb->db_version() ?? '',
291 231 'wp_version' => strval( $wp_version ),
292 232 );
233 +
234 + $dir_url = \plugin_dir_url( $plugin_file_path );
235 +
236 + self::$cache[ Interface_Constants::class ] = new Constants(
237 + $dir_path,
238 + $plugin_file_path,
239 + $dir_path . 'sequra.{storeId}.log',
240 + \plugin_basename( $plugin_file_path ),
241 + $dir_url,
242 + 'sequra/v1',
243 + $data,
244 + \get_plugin_data( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php', true, false ),
245 + $environment_data,
246 + $dir_path . 'templates/',
247 + $dir_path . 'assets',
248 + \untrailingslashit( $dir_url ) . '/assets'
249 + );
293 250 }
294 - return self::$cache['environment.data'];
251 +
252 + return self::$cache[ Interface_Constants::class ];
295 253 }
296 254 );
255 + }
297 256
298 - Reg::registerService(
299 - 'plugin.templates_path',
300 - static function () {
301 - if ( ! isset( self::$cache['plugin.templates_path'] ) ) {
302 - self::$cache['plugin.templates_path'] = Reg::getService( 'plugin.dir_path' ) . 'templates/';
303 - }
304 - return self::$cache['plugin.templates_path'];
305 - }
306 - );
307 - Reg::registerService(
308 - 'plugin.assets_path',
309 - static function () {
310 - if ( ! isset( self::$cache['plugin.assets_path'] ) ) {
311 - self::$cache['plugin.assets_path'] = Reg::getService( 'plugin.dir_path' ) . 'assets';
312 - }
313 - return self::$cache['plugin.assets_path'];
314 - }
315 - );
316 - Reg::registerService(
317 - 'plugin.assets_url',
318 - static function () {
319 - if ( ! isset( self::$cache['plugin.assets_url'] ) ) {
320 - self::$cache['plugin.assets_url'] = untrailingslashit( Reg::getService( 'plugin.dir_url' ) ) . '/assets';
321 - }
322 - return self::$cache['plugin.assets_url'];
323 - }
324 - );
257 + /**
258 + * Get the constants instance.
259 + *
260 + * @return Interface_Constants
261 + * @throws ServiceNotRegisteredException
262 + */
263 + private static function get_constants() {
264 + return Reg::getService( Interface_Constants::class );
325 265 }
326 266
327 267 /**
328 268 * Initializes services and utilities.
@@ -331,9 +271,9 @@
331 271 parent::initServices();
332 272
333 273 // Core Default.
334 274 Reg::registerService(
335 - LoggerConfiguration::class,
275 + LoggerConfiguration::class,
336 276 static function () {
337 277 if ( ! isset( self::$cache[ LoggerConfiguration::class ] ) ) {
338 278 $loggerConfig = LoggerConfiguration::getInstance();
339 279 if ( ! $loggerConfig->isDefaultLoggerEnabled() ) {
@@ -363,50 +303,58 @@
363 303 static function () {
364 304 return Reg::getService( Order_Status_Settings_Service::class );
365 305 }
366 306 );
307 + // Extend Configuration.
367 308 Reg::registerService(
368 309 Configuration::class,
369 310 static function () {
370 311 if ( ! isset( self::$cache[ Configuration::class ] ) ) {
371 - self::$cache[ Configuration::class ] = Configuration::getInstance();
312 + self::$cache[ Configuration::class ] = \SeQura\WC\Core\Extension\Infrastructure\Configuration\Configuration::getInstance();
372 313 }
373 314 return self::$cache[ Configuration::class ];
374 315 }
375 316 );
317 +
318 + /**
319 + * Initialize StoreContext with default store ID so any service that depends on StoreContext
320 + * will have the correct store ID set from the beginning. This will reduce the StoreContext::doWithStore
321 + * calls to the cases where it's really necessary to set a different store ID.
322 + */
376 323 Reg::registerService(
377 - \SeQura\Core\Infrastructure\Configuration\Configuration::CLASS_NAME,
324 + StoreIdProvider::class,
378 325 static function () {
379 - return Reg::getService( Configuration::class );
326 + if ( ! isset( self::$cache[ StoreIdProvider::class ] ) ) {
327 + self::$cache[ StoreIdProvider::class ] = new Store_Id_Provider();
328 + }
329 + return self::$cache[ StoreIdProvider::class ];
380 330 }
381 331 );
332 +
382 333 Reg::registerService(
383 334 Interface_Create_Order_Request_Builder::class,
384 335 static function () {
385 336 if ( ! isset( self::$cache[ Interface_Create_Order_Request_Builder::class ] ) ) {
386 337 self::$cache[ Interface_Create_Order_Request_Builder::class ] = new Create_Order_Request_Builder(
387 - Reg::getService( Interface_Payment_Service::class ),
388 338 Reg::getService( Interface_Cart_Service::class ),
389 - Reg::getService( Configuration::class ),
339 + Reg::getService( Interface_Platform_Provider::class ),
390 340 Reg::getService( Interface_Product_Service::class ),
391 341 Reg::getService( Interface_Order_Service::class ),
392 342 Reg::getService( Interface_I18n::class ),
393 343 Reg::getService( Interface_Shopper_Service::class ),
394 - Reg::getService( Interface_Logger_Service::class )
344 + Reg::getService( Interface_Logger_Service::class ),
345 + Reg::getService( Interface_Current_Order_Provider::class ),
346 + Reg::getService( MerchantOrderRequestBuilder::class ),
347 + Reg::getService( Interface_Order_Delivery_Method_Builder::class ),
348 + Reg::getService( Interface_Order_Address_Builder::class ),
349 + Reg::getService( Interface_Order_Customer_Builder::class ),
350 + Reg::getService( CredentialsService::class ),
351 + Reg::getService( SeQuraOrderRepositoryInterface::class )
395 352 );
396 353 }
397 354 return self::$cache[ Interface_Create_Order_Request_Builder::class ];
398 355 }
399 356 );
400 - Reg::registerService(
401 - AbstractItemFactory::class,
402 - static function () {
403 - if ( ! isset( self::$cache[ AbstractItemFactory::class ] ) ) {
404 - self::$cache[ AbstractItemFactory::class ] = new Item_Factory();
405 - }
406 - return self::$cache[ AbstractItemFactory::class ];
407 - }
408 - );
409 357
410 358 // Core Implementation.
411 359 Reg::registerService(
412 360 EncryptorInterface::class,
@@ -426,10 +374,8 @@
426 374 RepositoryRegistry::getRepository( ConnectionData::class ),
427 375 RepositoryRegistry::getRepository( StatisticalData::class ),
428 376 RepositoryRegistry::getRepository( SendReport::class ),
429 377 RepositoryRegistry::getRepository( QueueItem::class ),
430 - //phpcs:ignore
431 - // RepositoryRegistry::getRepository( SeQuraOrder::class ),
432 378 )
433 379 );
434 380 }
435 381 return self::$cache[ DisconnectServiceInterface::class ];
@@ -439,18 +385,46 @@
439 385 OrderReportServiceInterface::class,
440 386 static function () {
441 387 if ( ! isset( self::$cache[ OrderReportServiceInterface::class ] ) ) {
442 388 self::$cache[ OrderReportServiceInterface::class ] = new Order_Report_Service(
443 - Reg::getService( Configuration::CLASS_NAME ),
389 + Reg::getService( Interface_Platform_Provider::class ),
444 390 Reg::getService( Interface_Pricing_Service::class ),
445 391 Reg::getService( Interface_Cart_Service::class ),
446 392 Reg::getService( Interface_Order_Service::class ),
447 - Reg::getService( Interface_I18n::class )
393 + Reg::getService( Interface_I18n::class ),
394 + Reg::getService( Interface_Order_Delivery_Method_Builder::class ),
395 + Reg::getService( Interface_Order_Address_Builder::class ),
396 + Reg::getService( Interface_Order_Customer_Builder::class )
448 397 );
449 398 }
450 399 return self::$cache[ OrderReportServiceInterface::class ];
451 400 }
452 401 );
402 + Reg::registerService(
403 + MerchantDataProviderInterface::class,
404 + static function () {
405 + if ( ! isset( self::$cache[ MerchantDataProviderInterface::class ] ) ) {
406 + self::$cache[ MerchantDataProviderInterface::class ] = new Merchant_Data_Provider(
407 + Reg::getService( Interface_Current_Order_Provider::class ),
408 + Reg::getService( Interface_Constants::class ),
409 + Reg::getService( Interface_Product_Service::class ),
410 + Reg::getService( Interface_Cart_Service::class ),
411 + Reg::getService( Interface_Shopper_Service::class ),
412 + Reg::getService( StoreContext::class )
413 + );
414 + }
415 + return self::$cache[ MerchantDataProviderInterface::class ];
416 + }
417 + );
418 + Reg::registerService(
419 + OrderCreationInterface::class,
420 + static function () {
421 + if ( ! isset( self::$cache[ OrderCreationInterface::class ] ) ) {
422 + self::$cache[ OrderCreationInterface::class ] = new Order_Creation();
423 + }
424 + return self::$cache[ OrderCreationInterface::class ];
425 + }
426 + );
453 427
454 428
455 429 Reg::registerService(
456 430 Serializer::class,
@@ -483,9 +457,9 @@
483 457 VersionServiceInterface::class,
484 458 static function () {
485 459 if ( ! isset( self::$cache[ VersionServiceInterface::class ] ) ) {
486 460 self::$cache[ VersionServiceInterface::class ] = new Version_Service(
487 - Reg::getService( 'plugin.data' )['Version']
461 + self::get_constants()->get_plugin_data()['Version']
488 462 );
489 463 }
490 464 return self::$cache[ VersionServiceInterface::class ];
491 465 }
@@ -535,9 +509,10 @@
535 509 Interface_Log_File::class,
536 510 static function () {
537 511 if ( ! isset( self::$cache[ Interface_Log_File::class ] ) ) {
538 512 self::$cache[ Interface_Log_File::class ] = new Log_File(
539 - Reg::getService( 'plugin.log_file_path' )
513 + self::get_constants()->get_plugin_log_file_path(),
514 + Reg::getService( StoreContext::class )
540 515 );
541 516 }
542 517 return self::$cache[ Interface_Log_File::class ];
543 518 }
@@ -545,17 +520,66 @@
545 520 Reg::registerService(
546 521 Interface_Migration_Manager::class,
547 522 static function () {
548 523 if ( ! isset( self::$cache[ Interface_Migration_Manager::class ] ) ) {
524 + $configuration = Reg::getService( ConfigurationManager::CLASS_NAME );
525 + $wpdb = Reg::getService( \wpdb::class );
526 + /**
527 + * Order repository.
528 + *
529 + * @var Repository $order_repository
530 + */
531 + $order_repository = RepositoryRegistry::getRepository( SeQuraOrder::class );
532 + /**
533 + * Entity repository.
534 + *
535 + * @var Repository $entity_repository
536 + */
537 + $entity_repository = RepositoryRegistry::getRepository( ConfigEntity::class );
538 +
539 + /**
540 + * Queue item repository.
541 + *
542 + * @var Repository $queue_item_repository
543 + */
544 + $queue_item_repository = RepositoryRegistry::getRepository( QueueItem::class );
545 + /**
546 + * Encryptor service.
547 + *
548 + * @var EncryptorInterface $encryptor
549 + */
550 + $encryptor = Reg::getService( EncryptorInterface::class );
551 +
552 + /**
553 + * Store context service.
554 + *
555 + * @var StoreContext $store_context
556 + */
557 + $store_context = Reg::getService( StoreContext::class );
558 +
549 559 self::$cache[ Interface_Migration_Manager::class ] = new Migration_Manager(
550 - Reg::getService( 'plugin.basename' ),
551 - Reg::getService( Configuration::CLASS_NAME ),
552 - Reg::getService( 'plugin.data' )['Version'],
560 + self::get_constants()->get_plugin_basename(),
561 + $configuration,
562 + self::get_constants()->get_plugin_data()['Version'],
553 563 array(
554 - new Migration_Install_300(
555 - Reg::getService( \wpdb::class ),
556 - Reg::getService( Configuration::CLASS_NAME )
564 + new Migration_Install_300(
565 + $wpdb,
566 + $order_repository,
567 + $entity_repository,
568 + $queue_item_repository,
569 + $store_context
557 570 ),
571 + new Migration_Install_320(
572 + $wpdb,
573 + self::get_constants()->get_hook_add_order_indexes(),
574 + $entity_repository,
575 + $queue_item_repository
576 + ),
577 + new Migration_Install_400(
578 + $wpdb,
579 + $encryptor,
580 + $store_context,
581 + ),
558 582 )
559 583 );
560 584 }
561 585 return self::$cache[ Interface_Migration_Manager::class ];
@@ -570,28 +594,16 @@
570 594 return self::$cache[ Interface_I18n::class ];
571 595 }
572 596 );
573 597 Reg::registerService(
574 - Interface_Regex::class,
575 - static function () {
576 - if ( ! isset( self::$cache[ Interface_Regex::class ] ) ) {
577 - self::$cache[ Interface_Regex::class ] = new Regex();
578 - }
579 - return self::$cache[ Interface_Regex::class ];
580 - }
581 - );
582 - Reg::registerService(
583 598 Interface_Report_Service::class,
584 599 static function () {
585 600 if ( ! isset( self::$cache[ Interface_Report_Service::class ] ) ) {
586 601 self::$cache[ Interface_Report_Service::class ] = new Report_Service(
587 - Reg::getService( Configuration::class ),
588 - Reg::getService( StoreService::class ),
589 602 Reg::getService( ShopOrderService::class ),
590 603 Reg::getService( StatisticalDataRepositoryInterface::class ),
591 604 Reg::getService( CountryConfigurationRepositoryInterface::class ),
592 - Reg::getService( Interface_Order_Service::class ),
593 - Reg::getService( StoreContext::class )
605 + Reg::getService( Interface_Order_Service::class )
594 606 );
595 607 }
596 608 return self::$cache[ Interface_Report_Service::class ];
597 609 }
@@ -607,28 +619,17 @@
607 619 }
608 620 return self::$cache[ Interface_Logger_Service::class ];
609 621 }
610 622 );
623 +
611 624 Reg::registerService(
612 - Interface_Payment_Service::class,
613 - static function () {
614 - if ( ! isset( self::$cache[ Interface_Payment_Service::class ] ) ) {
615 - self::$cache[ Interface_Payment_Service::class ] = new Payment_Service(
616 - Reg::getService( Configuration::class ),
617 - Reg::getService( Interface_I18n::class )
618 - );
619 - }
620 - return self::$cache[ Interface_Payment_Service::class ];
621 - }
622 - );
623 - Reg::registerService(
624 625 Sequra_Payment_Gateway_Block_Support::class,
625 626 static function () {
626 627 if ( ! isset( self::$cache[ Sequra_Payment_Gateway_Block_Support::class ] ) ) {
627 628 self::$cache[ Sequra_Payment_Gateway_Block_Support::class ] = new Sequra_Payment_Gateway_Block_Support(
628 - Reg::getService( 'plugin.assets_path' ),
629 - Reg::getService( 'plugin.assets_url' ),
630 - Reg::getService( 'plugin.data' )['Version']
629 + self::get_constants()->get_plugin_assets_path(),
630 + self::get_constants()->get_plugin_assets_url(),
631 + self::get_constants()->get_plugin_data()['Version']
631 632 );
632 633 }
633 634 return self::$cache[ Sequra_Payment_Gateway_Block_Support::class ];
634 635 }
@@ -645,15 +646,27 @@
645 646 Reg::registerService(
646 647 Interface_Order_Service::class,
647 648 static function () {
648 649 if ( ! isset( self::$cache[ Interface_Order_Service::class ] ) ) {
650 + /**
651 + * This will return SeQura_Order_Repository that implements Interface_Deletable_Repository and Interface_Table_Migration_Repository.
652 + *
653 + * @var SeQura_Order_Repository $repository
654 + */
655 + $repository = RepositoryRegistry::getRepository( SeQuraOrder::class );
656 +
649 657 self::$cache[ Interface_Order_Service::class ] = new Order_Service(
650 - Reg::getService( Interface_Payment_Service::class ),
658 + Reg::getService( SeQuraOrderRepositoryInterface::class ),
651 659 Reg::getService( Interface_Pricing_Service::class ),
652 660 Reg::getService( OrderStatusSettingsService::class ),
653 - Reg::getService( Configuration::class ),
654 661 Reg::getService( Interface_Cart_Service::class ),
655 - Reg::getService( StoreContext::class )
662 + Reg::getService( Interface_Logger_Service::class ),
663 + Reg::getService( Interface_Time_Checker_Service::class ),
664 + $repository,
665 + $repository,
666 + self::get_constants()->get_payment_gateway_id(),
667 + Reg::getService( ConnectionService::class ),
668 + Reg::getService( OrderService::class )
656 669 );
657 670 }
658 671 return self::$cache[ Interface_Order_Service::class ];
659 672 }
@@ -663,11 +676,11 @@
663 676 static function () {
664 677 if ( ! isset( self::$cache[ Interface_Cart_Service::class ] ) ) {
665 678 self::$cache[ Interface_Cart_Service::class ] = new Cart_Service(
666 679 Reg::getService( Interface_Product_Service::class ),
667 - Reg::getService( Configuration::class ),
668 680 Reg::getService( Interface_Pricing_Service::class ),
669 - Reg::getService( Interface_Logger_Service::class )
681 + Reg::getService( Interface_Logger_Service::class ),
682 + Reg::getService( Interface_Shopper_Service::class )
670 683 );
671 684 }
672 685 return self::$cache[ Interface_Cart_Service::class ];
673 686 }
@@ -676,11 +689,11 @@
676 689 Interface_Product_Service::class,
677 690 static function () {
678 691 if ( ! isset( self::$cache[ Interface_Product_Service::class ] ) ) {
679 692 self::$cache[ Interface_Product_Service::class ] = new Product_Service(
680 - Reg::getService( Configuration::class ),
681 693 Reg::getService( Interface_Pricing_Service::class ),
682 - Reg::getService( Interface_Regex::class )
694 + Reg::getService( RegexProvider::class ),
695 + Reg::getService( StoreContext::class )
683 696 );
684 697 }
685 698 return self::$cache[ Interface_Product_Service::class ];
686 699 }
@@ -688,9 +701,11 @@
688 701 Reg::registerService(
689 702 Interface_Shopper_Service::class,
690 703 static function () {
691 704 if ( ! isset( self::$cache[ Interface_Shopper_Service::class ] ) ) {
692 - self::$cache[ Interface_Shopper_Service::class ] = new Shopper_Service();
705 + self::$cache[ Interface_Shopper_Service::class ] = new Shopper_Service(
706 + Reg::getService( StoreContext::class )
707 + );
693 708 }
694 709 return self::$cache[ Interface_Shopper_Service::class ];
695 710 }
696 711 );
@@ -699,9 +714,12 @@
699 714 static function () {
700 715 if ( ! isset( self::$cache[ ShopOrderService::class ] ) ) {
701 716 self::$cache[ ShopOrderService::class ] = new Shop_Order_Service(
702 717 Reg::getService( SeQuraOrderRepositoryInterface::class ),
703 - Reg::getService( Interface_Logger_Service::class )
718 + Reg::getService( Interface_Logger_Service::class ),
719 + Reg::getService( Interface_Create_Order_Request_Builder::class ),
720 + Reg::getService( Interface_Current_Order_Provider::class ),
721 + Reg::getService( OrderService::class )
704 722 );
705 723 }
706 724 return self::$cache[ ShopOrderService::class ];
707 725 }
@@ -706,16 +724,145 @@
706 724 return self::$cache[ ShopOrderService::class ];
707 725 }
708 726 );
709 727 Reg::registerService(
710 - Interface_Assets::class,
728 + Interface_Time_Checker_Service::class,
711 729 static function () {
712 - if ( ! isset( self::$cache[ Interface_Assets::class ] ) ) {
713 - self::$cache[ Interface_Assets::class ] = new Assets();
730 + if ( ! isset( self::$cache[ Interface_Time_Checker_Service::class ] ) ) {
731 + self::$cache[ Interface_Time_Checker_Service::class ] = new Time_Checker_Service();
714 732 }
715 - return self::$cache[ Interface_Assets::class ];
733 + return self::$cache[ Interface_Time_Checker_Service::class ];
716 734 }
717 735 );
736 +
737 + Reg::registerService(
738 + ProductServiceInterface::class,
739 + static function () {
740 + if ( ! isset( self::$cache[ ProductServiceInterface::class ] ) ) {
741 + self::$cache[ ProductServiceInterface::class ] = new Core_Product_Service();
742 + }
743 + return self::$cache[ ProductServiceInterface::class ];
744 + }
745 + );
746 + Reg::registerService(
747 + WidgetConfiguratorInterface::class,
748 + static function () {
749 + if ( ! isset( self::$cache[ WidgetConfiguratorInterface::class ] ) ) {
750 + self::$cache[ WidgetConfiguratorInterface::class ] = new Widget_Configurator(
751 + Reg::getService( Interface_I18n::class )
752 + );
753 + }
754 + return self::$cache[ WidgetConfiguratorInterface::class ];
755 + }
756 + );
757 +
758 + Reg::registerService(
759 + MiniWidgetMessagesProviderInterface::class,
760 + static function () {
761 + if ( ! isset( self::$cache[ MiniWidgetMessagesProviderInterface::class ] ) ) {
762 + self::$cache[ MiniWidgetMessagesProviderInterface::class ] = new Mini_Widget_Messages_Provider(
763 + Reg::getService( Interface_I18n::class )
764 + );
765 + }
766 + return self::$cache[ MiniWidgetMessagesProviderInterface::class ];
767 + }
768 + );
769 +
770 + Reg::registerService(
771 + Interface_Current_Order_Provider::class,
772 + static function () {
773 + if ( ! isset( self::$cache[ Interface_Current_Order_Provider::class ] ) ) {
774 + self::$cache[ Interface_Current_Order_Provider::class ] = new Current_Order_Provider();
775 + }
776 + return self::$cache[ Interface_Current_Order_Provider::class ];
777 + }
778 + );
779 +
780 + Reg::registerService(
781 + Interface_Platform_Provider::class,
782 + static function () {
783 + if ( ! isset( self::$cache[ Interface_Platform_Provider::class ] ) ) {
784 + self::$cache[ Interface_Platform_Provider::class ] = new Platform_Provider(
785 + Reg::getService( Interface_Constants::class )
786 + );
787 + }
788 + return self::$cache[ Interface_Platform_Provider::class ];
789 + }
790 + );
791 +
792 + Reg::registerService(
793 + Interface_Payment_Method_Service::class,
794 + static function () {
795 + if ( ! isset( self::$cache[ Interface_Payment_Method_Service::class ] ) ) {
796 + self::$cache[ Interface_Payment_Method_Service::class ] = new Payment_Method_Service(
797 + Reg::getService( Interface_Create_Order_Request_Builder::class ),
798 + Reg::getService( Interface_Order_Service::class ),
799 + Reg::getService( Interface_Logger_Service::class ),
800 + Reg::getService( Interface_Current_Order_Provider::class ),
801 + Reg::getService( StoreContext::class )
802 + );
803 + }
804 + return self::$cache[ Interface_Payment_Method_Service::class ];
805 + }
806 + );
807 +
808 + Reg::registerService(
809 + Interface_Widgets_Service::class,
810 + static function () {
811 + if ( ! isset( self::$cache[ Interface_Widgets_Service::class ] ) ) {
812 + self::$cache[ Interface_Widgets_Service::class ] = new Widgets_Service(
813 + Reg::getService( Interface_Logger_Service::class ),
814 + Reg::getService( Interface_I18n::class ),
815 + Reg::getService( Interface_Shopper_Service::class ),
816 + Reg::getService( WidgetConfiguratorInterface::class ),
817 + Reg::getService( StoreContext::class )
818 + );
819 + }
820 + return self::$cache[ Interface_Widgets_Service::class ];
821 + }
822 + );
823 + Reg::registerService(
824 + Interface_Settings_Service::class,
825 + static function () {
826 + if ( ! isset( self::$cache[ Interface_Settings_Service::class ] ) ) {
827 + self::$cache[ Interface_Settings_Service::class ] = new Settings_Service();
828 + }
829 + return self::$cache[ Interface_Settings_Service::class ];
830 + }
831 + );
832 + Reg::registerService(
833 + Interface_Order_Address_Builder::class,
834 + static function () {
835 + if ( ! isset( self::$cache[ Interface_Order_Address_Builder::class ] ) ) {
836 + self::$cache[ Interface_Order_Address_Builder::class ] = new Order_Address_Builder(
837 + Reg::getService( Interface_Shopper_Service::class )
838 + );
839 + }
840 + return self::$cache[ Interface_Order_Address_Builder::class ];
841 + }
842 + );
843 + Reg::registerService(
844 + Interface_Order_Customer_Builder::class,
845 + static function () {
846 + if ( ! isset( self::$cache[ Interface_Order_Customer_Builder::class ] ) ) {
847 + self::$cache[ Interface_Order_Customer_Builder::class ] = new Order_Customer_Builder(
848 + Reg::getService( Interface_Shopper_Service::class ),
849 + Reg::getService( OrderStatusSettingsService::class ),
850 + Reg::getService( Interface_Pricing_Service::class )
851 + );
852 + }
853 + return self::$cache[ Interface_Order_Customer_Builder::class ];
854 + }
855 + );
856 + Reg::registerService(
857 + Interface_Order_Delivery_Method_Builder::class,
858 + static function () {
859 + if ( ! isset( self::$cache[ Interface_Order_Delivery_Method_Builder::class ] ) ) {
860 + self::$cache[ Interface_Order_Delivery_Method_Builder::class ] = new Order_Delivery_Method_Builder();
861 + }
862 + return self::$cache[ Interface_Order_Delivery_Method_Builder::class ];
863 + }
864 + );
718 865 }
719 866
720 867 /**
721 868 * Initializes repositories.
@@ -734,30 +881,8 @@
734 881 );
735 882
736 883 parent::initRepositories();
737 884
738 - // Extend GeneralSettingsRepository.
739 - Reg::registerService(
740 - GeneralSettingsRepositoryInterface::class,
741 - static function () {
742 - return new General_Settings_Repository(
743 - RepositoryRegistry::getRepository( GeneralSettings::getClassName() ),
744 - Reg::getService( StoreContext::class )
745 - );
746 - }
747 - );
748 -
749 - // Extend WidgetSettingsRepository.
750 - Reg::registerService(
751 - WidgetSettingsRepositoryInterface::class,
752 - static function () {
753 - return new Widget_Settings_Repository(
754 - RepositoryRegistry::getRepository( WidgetSettings::getClassName() ),
755 - Reg::getService( StoreContext::class )
756 - );
757 - }
758 - );
759 -
760 885 RepositoryRegistry::registerRepository( ConfigEntity::class, Entity_Repository::class );
761 886 RepositoryRegistry::registerRepository( QueueItem::class, Queue_Item_Repository::class );
762 887 RepositoryRegistry::registerRepository( Process::class, Entity_Repository::class );
763 888 RepositoryRegistry::registerRepository( ConnectionData::class, Entity_Repository::class );
@@ -768,8 +893,11 @@
768 893 RepositoryRegistry::registerRepository( SeQuraOrder::class, SeQura_Order_Repository::class );
769 894 RepositoryRegistry::registerRepository( WidgetSettings::class, Entity_Repository::class );
770 895 RepositoryRegistry::registerRepository( SendReport::class, Entity_Repository::class );
771 896 RepositoryRegistry::registerRepository( TransactionLog::class, Entity_Repository::class );
897 + RepositoryRegistry::registerRepository( PaymentMethod::class, Entity_Repository::class );
898 + RepositoryRegistry::registerRepository( Credentials::class, Entity_Repository::class );
899 + RepositoryRegistry::registerRepository( Deployment::class, Entity_Repository::class );
772 900 }
773 901
774 902 /**
775 903 * Initializes controllers.
@@ -776,41 +904,20 @@
776 904 */
777 905 protected static function initControllers(): void {
778 906 parent::initControllers();
779 907
780 - // Extend GeneralSettingsController.
781 - Reg::registerService(
782 - GeneralSettingsController::class,
783 - static function () {
784 - return new General_Settings_Controller(
785 - Reg::getService( GeneralSettingsService::class ),
786 - Reg::getService( CategoryService::class )
787 - );
788 - }
789 - );
790 -
791 - // Extend PromotionalWidgetsController.
792 - Reg::registerService(
793 - PromotionalWidgetsController::class,
794 - static function () {
795 - return new Promotional_Widgets_Controller(
796 - Reg::getService( WidgetSettingsService::class )
797 - );
798 - }
799 - );
800 -
801 908 // Plugin controllers.
802 909 Reg::registerService(
803 910 Interface_I18n_Controller::class,
804 911 static function () {
805 912 if ( ! isset( self::$cache[ Interface_I18n_Controller::class ] ) ) {
806 - $data = Reg::getService( 'plugin.data' );
913 + $data = self::get_constants()->get_plugin_data();
807 914 $domain = $data['TextDomain'];
808 - self::$cache[ Interface_I18n_Controller::class ] = new I18n_Controller(
915 + self::$cache[ Interface_I18n_Controller::class ] = new I18n_Controller(
809 916 $domain . $data['DomainPath'],
810 917 $domain,
811 918 Reg::getService( Interface_Logger_Service::class ),
812 - Reg::getService( 'plugin.templates_path' )
919 + self::get_constants()->get_plugin_templates_path()
813 920 );
814 921 }
815 922 return self::$cache[ Interface_I18n_Controller::class ];
816 923 }
@@ -818,21 +925,21 @@
818 925 Reg::registerService(
819 926 Interface_Assets_Controller::class,
820 927 static function () {
821 928 if ( ! isset( self::$cache[ Interface_Assets_Controller::class ] ) ) {
822 - $env_data = (array) Reg::getService( 'environment.data' );
929 + $env_data = self::get_constants()->get_environment_data();
823 930 self::$cache[ Interface_Assets_Controller::class ] = new Assets_Controller(
824 - Reg::getService( 'plugin.assets_url' ),
825 - Reg::getService( 'plugin.assets_path' ),
826 - Reg::getService( 'plugin.data' )['Version'],
931 + self::get_constants()->get_plugin_assets_url(),
932 + self::get_constants()->get_plugin_assets_path(),
933 + self::get_constants()->get_plugin_data()['Version'],
827 934 $env_data['wp_version'] ?? '',
828 935 Reg::getService( Interface_I18n::class ),
829 936 Reg::getService( Interface_Logger_Service::class ),
830 - Reg::getService( 'plugin.templates_path' ),
831 - Reg::getService( Configuration::class ),
832 - Reg::getService( Interface_Assets::class ),
937 + self::get_constants()->get_plugin_templates_path(),
938 + Reg::getService( Interface_Settings_Service::class ),
833 939 Reg::getService( Interface_Payment_Method_Service::class ),
834 - Reg::getService( Interface_Regex::class )
940 + Reg::getService( RegexProvider::class ),
941 + Reg::getService( Interface_Widgets_Service::class )
835 942 );
836 943 }
837 944 return self::$cache[ Interface_Assets_Controller::class ];
838 945 }
@@ -841,12 +948,12 @@
841 948 Interface_Settings_Controller::class,
842 949 static function () {
843 950 if ( ! isset( self::$cache[ Interface_Settings_Controller::class ] ) ) {
844 951 self::$cache[ Interface_Settings_Controller::class ] = new Settings_Controller(
845 - Reg::getService( 'plugin.templates_path' ),
846 - Reg::getService( Configuration::class ),
952 + self::get_constants()->get_plugin_templates_path(),
953 + Reg::getService( Interface_Settings_Service::class ),
847 954 Reg::getService( Interface_Logger_Service::class ),
848 - Reg::getService( 'plugin.basename' )
955 + self::get_constants()->get_plugin_basename()
849 956 );
850 957 }
851 958 return self::$cache[ Interface_Settings_Controller::class ];
852 959 }
@@ -856,9 +963,9 @@
856 963 static function () {
857 964 if ( ! isset( self::$cache[ Interface_Payment_Controller::class ] ) ) {
858 965 self::$cache[ Interface_Payment_Controller::class ] = new Payment_Controller(
859 966 Reg::getService( Interface_Logger_Service::class ),
860 - Reg::getService( 'plugin.templates_path' ),
967 + self::get_constants()->get_plugin_templates_path(),
861 968 Reg::getService( Interface_Order_Service::class )
862 969 );
863 970 }
864 971 return self::$cache[ Interface_Payment_Controller::class ];
@@ -869,15 +976,12 @@
869 976 static function () {
870 977 if ( ! isset( self::$cache[ Interface_Product_Controller::class ] ) ) {
871 978 self::$cache[ Interface_Product_Controller::class ] = new Product_Controller(
872 979 Reg::getService( Interface_Logger_Service::class ),
873 - Reg::getService( 'plugin.templates_path' ),
874 - Reg::getService( Configuration::class ),
980 + self::get_constants()->get_plugin_templates_path(),
875 981 Reg::getService( Interface_Product_Service::class ),
876 - Reg::getService( Interface_Payment_Service::class ),
877 - Reg::getService( Interface_Payment_Method_Service::class ),
878 - Reg::getService( Interface_I18n::class ),
879 - Reg::getService( Interface_Regex::class )
982 + Reg::getService( RegexProvider::class ),
983 + Reg::getService( Interface_Widgets_Service::class )
880 984 );
881 985 }
882 986 return self::$cache[ Interface_Product_Controller::class ];
883 987 }
@@ -887,9 +991,9 @@
887 991 static function () {
888 992 if ( ! isset( self::$cache[ Interface_Async_Process_Controller::class ] ) ) {
889 993 self::$cache[ Interface_Async_Process_Controller::class ] = new Async_Process_Controller(
890 994 Reg::getService( Interface_Logger_Service::class ),
891 - Reg::getService( 'plugin.templates_path' ),
995 + self::get_constants()->get_plugin_templates_path(),
892 996 Reg::getService( Interface_Report_Service::class )
893 997 );
894 998 }
895 999 return self::$cache[ Interface_Async_Process_Controller::class ];
@@ -900,9 +1004,9 @@
900 1004 static function () {
901 1005 if ( ! isset( self::$cache[ Interface_Order_Controller::class ] ) ) {
902 1006 self::$cache[ Interface_Order_Controller::class ] = new Order_Controller(
903 1007 Reg::getService( Interface_Logger_Service::class ),
904 - Reg::getService( 'plugin.templates_path' ),
1008 + self::get_constants()->get_plugin_templates_path(),
905 1009 Reg::getService( Interface_Order_Service::class )
906 1010 );
907 1011 }
908 1012 return self::$cache[ Interface_Order_Controller::class ];
@@ -912,10 +1016,11 @@
912 1016 Onboarding_REST_Controller::class,
913 1017 static function () {
914 1018 if ( ! isset( self::$cache[ Onboarding_REST_Controller::class ] ) ) {
915 1019 self::$cache[ Onboarding_REST_Controller::class ] = new Onboarding_REST_Controller(
916 - Reg::getService( 'plugin.rest_namespace' ),
917 - Reg::getService( Interface_Logger_Service::class )
1020 + self::get_constants()->get_plugin_rest_namespace(),
1021 + Reg::getService( Interface_Logger_Service::class ),
1022 + Reg::getService( RegexProvider::class )
918 1023 );
919 1024 }
920 1025 return self::$cache[ Onboarding_REST_Controller::class ];
921 1026 }
@@ -924,11 +1029,11 @@
924 1029 Payment_REST_Controller::class,
925 1030 static function () {
926 1031 if ( ! isset( self::$cache[ Payment_REST_Controller::class ] ) ) {
927 1032 self::$cache[ Payment_REST_Controller::class ] = new Payment_REST_Controller(
928 - Reg::getService( 'plugin.rest_namespace' ),
1033 + self::get_constants()->get_plugin_rest_namespace(),
929 1034 Reg::getService( Interface_Logger_Service::class ),
930 - Reg::getService( Interface_Payment_Method_Service::class )
1035 + Reg::getService( RegexProvider::class )
931 1036 );
932 1037 }
933 1038 return self::$cache[ Payment_REST_Controller::class ];
934 1039 }
@@ -937,10 +1042,12 @@
937 1042 General_Settings_REST_Controller::class,
938 1043 static function () {
939 1044 if ( ! isset( self::$cache[ General_Settings_REST_Controller::class ] ) ) {
940 1045 self::$cache[ General_Settings_REST_Controller::class ] = new General_Settings_REST_Controller(
941 - Reg::getService( 'plugin.rest_namespace' ),
942 - Reg::getService( Interface_Logger_Service::class )
1046 + self::get_constants()->get_plugin_rest_namespace(),
1047 + Reg::getService( Interface_Logger_Service::class ),
1048 + Reg::getService( RegexProvider::class ),
1049 + Reg::getService( StoreContext::class )
943 1050 );
944 1051 }
945 1052 return self::$cache[ General_Settings_REST_Controller::class ];
946 1053 }
@@ -949,27 +1056,14 @@
949 1056 Log_REST_Controller::class,
950 1057 static function () {
951 1058 if ( ! isset( self::$cache[ Log_REST_Controller::class ] ) ) {
952 1059 self::$cache[ Log_REST_Controller::class ] = new Log_REST_Controller(
953 - Reg::getService( 'plugin.rest_namespace' ),
954 - Reg::getService( Interface_Logger_Service::class )
1060 + self::get_constants()->get_plugin_rest_namespace(),
1061 + Reg::getService( Interface_Logger_Service::class ),
1062 + Reg::getService( RegexProvider::class )
955 1063 );
956 1064 }
957 1065 return self::$cache[ Log_REST_Controller::class ];
958 - }
959 - );
960 - Reg::registerService(
961 - Interface_Payment_Method_Service::class,
962 - static function () {
963 - if ( ! isset( self::$cache[ Interface_Payment_Method_Service::class ] ) ) {
964 - self::$cache[ Interface_Payment_Method_Service::class ] = new Payment_Method_Service(
965 - Reg::getService( Configuration::class ),
966 - Reg::getService( Interface_Create_Order_Request_Builder::class ),
967 - Reg::getService( Interface_Order_Service::class ),
968 - Reg::getService( Interface_Logger_Service::class )
969 - );
970 - }
971 - return self::$cache[ Interface_Payment_Method_Service::class ];
972 1066 }
973 1067 );
974 1068 }
975 1069 }