PluginProbe
seQura / 3.0.2
seQura v3.0.2
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
sequra / src / class-bootstrap.php

class-bootstrap.php in seQura 3.0.2, at src/class-bootstrap.php

967 lines 36.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Implementation for the core bootstrap class.
4 *
5 * @package SeQura/WC
6 */
7
8 namespace SeQura\WC;
9
10 use SeQura\Core\BusinessLogic\AdminAPI\GeneralSettings\GeneralSettingsController;
11 use SeQura\Core\BusinessLogic\AdminAPI\PromotionalWidgets\PromotionalWidgetsController;
12 use SeQura\Core\BusinessLogic\BootstrapComponent;
13 use SeQura\Core\BusinessLogic\DataAccess\ConnectionData\Entities\ConnectionData;
14 use SeQura\Core\BusinessLogic\DataAccess\OrderSettings\Entities\OrderStatusSettings;
15 use SeQura\Core\BusinessLogic\DataAccess\PromotionalWidgets\Entities\WidgetSettings;
16 use SeQura\Core\BusinessLogic\DataAccess\SendReport\Entities\SendReport;
17 use SeQura\Core\BusinessLogic\DataAccess\StatisticalData\Entities\StatisticalData;
18 use SeQura\Core\BusinessLogic\DataAccess\TransactionLog\Entities\TransactionLog;
19 use SeQura\Core\BusinessLogic\DataAccess\CountryConfiguration\Entities\CountryConfiguration;
20 use SeQura\Core\BusinessLogic\DataAccess\GeneralSettings\Entities\GeneralSettings;
21 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 use SeQura\Core\BusinessLogic\Domain\Integration\Category\CategoryServiceInterface;
26 use SeQura\Core\BusinessLogic\Domain\Integration\Disconnect\DisconnectServiceInterface;
27 use SeQura\Core\BusinessLogic\Domain\Integration\OrderReport\OrderReportServiceInterface;
28 use SeQura\Core\BusinessLogic\Domain\Integration\SellingCountries\SellingCountriesServiceInterface;
29 use SeQura\Core\BusinessLogic\Domain\Integration\ShopOrderStatuses\ShopOrderStatusesServiceInterface;
30 use SeQura\Core\BusinessLogic\Domain\Integration\Store\StoreServiceInterface;
31 use SeQura\Core\BusinessLogic\Domain\Integration\Version\VersionServiceInterface;
32 use SeQura\Core\BusinessLogic\Domain\Multistore\StoreContext;
33 use SeQura\Core\BusinessLogic\Domain\Order\Models\OrderRequest\Item\AbstractItemFactory;
34 use SeQura\Core\BusinessLogic\Domain\Order\Models\SeQuraOrder;
35 use SeQura\Core\BusinessLogic\Domain\Order\RepositoryContracts\SeQuraOrderRepositoryInterface;
36 use SeQura\Core\BusinessLogic\Domain\OrderStatusSettings\RepositoryContracts\OrderStatusSettingsRepositoryInterface;
37 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 use SeQura\Core\BusinessLogic\Domain\StatisticalData\RepositoryContracts\StatisticalDataRepositoryInterface;
41 use SeQura\Core\BusinessLogic\Domain\Stores\Services\StoreService;
42 use SeQura\Core\BusinessLogic\Utility\EncryptorInterface;
43 use SeQura\Core\BusinessLogic\Webhook\Services\ShopOrderService;
44 use SeQura\Core\Infrastructure\Configuration\ConfigEntity;
45 use SeQura\Core\Infrastructure\Logger\Interfaces\DefaultLoggerAdapter;
46 use SeQura\Core\Infrastructure\Logger\Interfaces\ShopLoggerAdapter;
47 use SeQura\Core\Infrastructure\Logger\LoggerConfiguration;
48 use SeQura\Core\Infrastructure\ORM\RepositoryRegistry;
49 use SeQura\Core\Infrastructure\Serializer\Concrete\JsonSerializer;
50 use SeQura\Core\Infrastructure\Serializer\Serializer;
51 use SeQura\Core\Infrastructure\ServiceRegister as Reg;
52 use SeQura\Core\Infrastructure\TaskExecution\Process;
53 use SeQura\Core\Infrastructure\TaskExecution\QueueItem;
54 use SeQura\Core\Infrastructure\Utility\TimeProvider;
55 use SeQura\WC\Controllers\Hooks\Asset\Assets_Controller;
56 use SeQura\WC\Controllers\Hooks\Asset\Interface_Assets_Controller;
57 use SeQura\WC\Controllers\Hooks\Product\Interface_Product_Controller;
58 use SeQura\WC\Controllers\Hooks\Product\Product_Controller;
59 use SeQura\WC\Controllers\Hooks\I18n\I18n_Controller;
60 use SeQura\WC\Controllers\Hooks\I18n\Interface_I18n_Controller;
61 use SeQura\WC\Controllers\Hooks\Order\Interface_Order_Controller;
62 use SeQura\WC\Controllers\Hooks\Order\Order_Controller;
63 use SeQura\WC\Controllers\Hooks\Payment\Interface_Payment_Controller;
64 use SeQura\WC\Controllers\Hooks\Payment\Payment_Controller;
65 use SeQura\WC\Controllers\Hooks\Process\Async_Process_Controller;
66 use SeQura\WC\Controllers\Hooks\Process\Interface_Async_Process_Controller;
67 use SeQura\WC\Controllers\Hooks\Settings\Interface_Settings_Controller;
68 use SeQura\WC\Controllers\Hooks\Settings\Settings_Controller;
69 use SeQura\WC\Controllers\Rest\General_Settings_REST_Controller;
70 use SeQura\WC\Controllers\Rest\Log_REST_Controller;
71 use SeQura\WC\Controllers\Rest\Onboarding_REST_Controller;
72 use SeQura\WC\Controllers\Rest\Payment_REST_Controller;
73 use SeQura\WC\Core\BusinessLogic\Domain\Order\Models\OrderRequest\Item\Item_Factory;
74 use SeQura\WC\Core\Extension\BusinessLogic\Domain\Order\Builders\Interface_Create_Order_Request_Builder;
75 use SeQura\WC\Core\Extension\BusinessLogic\Domain\OrderStatusSettings\Services\Order_Status_Settings_Service;
76 use SeQura\WC\Core\Extension\Infrastructure\Configuration\Configuration;
77 use SeQura\WC\Core\Implementation\BusinessLogic\Domain\Integration\Category\Category_Service;
78 use SeQura\WC\Core\Implementation\BusinessLogic\Domain\Integration\Disconnect\Disconnect_Service;
79 use SeQura\WC\Core\Implementation\BusinessLogic\Domain\Integration\ShopOrderStatuses\Shop_Order_Status_Service;
80 use SeQura\WC\Core\Implementation\BusinessLogic\Domain\Order\Builders\Create_Order_Request_Builder;
81 use SeQura\WC\Core\Implementation\BusinessLogic\Utility\Encryptor;
82 use SeQura\WC\Core\Implementation\BusinessLogic\Webhook\Services\Shop_Order_Service;
83 use SeQura\WC\Core\Implementation\Infrastructure\Logger\Interfaces\Default_Logger_Adapter;
84 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 use SeQura\WC\Core\Implementation\BusinessLogic\Domain\Integration\OrderReport\Order_Report_Service;
90 use SeQura\WC\Repositories\Entity_Repository;
91 use SeQura\WC\Repositories\Migrations\Migration_Install_300;
92 use SeQura\WC\Repositories\Queue_Item_Repository;
93 use SeQura\WC\Repositories\SeQura_Order_Repository;
94 use SeQura\WC\Services\Assets\Assets;
95 use SeQura\WC\Services\Assets\Interface_Assets;
96 use SeQura\WC\Services\Cart\Cart_Service;
97 use SeQura\WC\Services\Cart\Interface_Cart_Service;
98 use SeQura\WC\Services\Core\Selling_Countries_Service;
99 use SeQura\WC\Services\Core\Store_Service;
100 use SeQura\WC\Services\Core\Version_Service;
101 use SeQura\WC\Services\Shopper\Shopper_Service;
102 use SeQura\WC\Services\Shopper\Interface_Shopper_Service;
103 use SeQura\WC\Services\I18n\I18n;
104 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;
109 use SeQura\WC\Services\Migration\Interface_Migration_Manager;
110 use SeQura\WC\Services\Migration\Migration_Manager;
111 use SeQura\WC\Services\Order\Interface_Order_Service;
112 use SeQura\WC\Services\Order\Order_Service;
113 use SeQura\WC\Services\Payment\Interface_Payment_Method_Service;
114 use SeQura\WC\Services\Payment\Interface_Payment_Service;
115 use SeQura\WC\Services\Payment\Payment_Method_Service;
116 use SeQura\WC\Services\Payment\Payment_Service;
117 use SeQura\WC\Services\Payment\Sequra_Payment_Gateway_Block_Support;
118 use SeQura\WC\Services\Pricing\Interface_Pricing_Service;
119 use SeQura\WC\Services\Pricing\Pricing_Service;
120 use SeQura\WC\Services\Product\Interface_Product_Service;
121 use SeQura\WC\Services\Product\Product_Service;
122 use SeQura\WC\Services\Regex\Interface_Regex;
123 use SeQura\WC\Services\Regex\Regex;
124 use SeQura\WC\Services\Report\Interface_Report_Service;
125 use SeQura\WC\Services\Report\Report_Service;
126
127 /**
128 * Implementation for the core bootstrap class.
129 */
130 class Bootstrap extends BootstrapComponent {
131
132 /**
133 * Cache for Service instances.
134 *
135 * @var array<string, mixed>
136 */
137 private static $cache = array();
138
139 /**
140 * Initialize the bootstrap.
141 */
142 public static function init(): void {
143 self::initConstants();
144 parent::init();
145
146 Reg::registerService(
147 Plugin::class,
148 static function () {
149 return new Plugin(
150 Reg::getService( 'plugin.data' ),
151 Reg::getService( 'plugin.file_path' ),
152 Reg::getService( 'plugin.basename' ),
153 Reg::getService( Interface_Migration_Manager::class ),
154 Reg::getService( Interface_I18n_Controller::class ),
155 Reg::getService( Interface_Assets_Controller::class ),
156 Reg::getService( Interface_Settings_Controller::class ),
157 Reg::getService( Interface_Payment_Controller::class ),
158 Reg::getService( General_Settings_REST_Controller::class ),
159 Reg::getService( Onboarding_REST_Controller::class ),
160 Reg::getService( Payment_REST_Controller::class ),
161 Reg::getService( Log_REST_Controller::class ),
162 Reg::getService( Interface_Product_Controller::class ),
163 Reg::getService( Interface_Async_Process_Controller::class ),
164 Reg::getService( Interface_Order_Controller::class )
165 );
166 }
167 );
168 }
169
170 /**
171 * Initializes constants.
172 */
173 public static function initConstants(): void {
174 Reg::registerService(
175 'plugin.dir_path',
176 static function () {
177 if ( ! isset( self::$cache['plugin.dir_path'] ) ) {
178 self::$cache['plugin.dir_path'] = trailingslashit( dirname( __DIR__, 1 ) );
179 }
180 return self::$cache['plugin.dir_path'];
181 }
182 );
183 Reg::registerService(
184 'plugin.file_path',
185 static function () {
186 if ( ! isset( self::$cache['plugin.file_path'] ) ) {
187 self::$cache['plugin.file_path'] = Reg::getService( 'plugin.dir_path' ) . 'sequra.php';
188 }
189 return self::$cache['plugin.file_path'];
190 }
191 );
192 Reg::registerService(
193 'plugin.log_file_path',
194 static function () {
195 if ( ! isset( self::$cache['plugin.log_file_path'] ) ) {
196 self::$cache['plugin.log_file_path'] = Reg::getService( 'plugin.dir_path' ) . 'sequra.{storeId}.log';
197 }
198 return self::$cache['plugin.log_file_path'];
199 }
200 );
201
202 Reg::registerService(
203 'plugin.basename',
204 static function () {
205 if ( ! isset( self::$cache['plugin.basename'] ) ) {
206 self::$cache['plugin.basename'] = plugin_basename( Reg::getService( 'plugin.dir_path' ) . 'sequra.php' );
207 }
208 return self::$cache['plugin.basename'];
209 }
210 );
211
212 Reg::registerService(
213 'plugin.dir_url',
214 static function () {
215 if ( ! isset( self::$cache['plugin.dir_url'] ) ) {
216 self::$cache['plugin.dir_url'] = plugin_dir_url( Reg::getService( 'plugin.file_path' ) );
217 }
218 return self::$cache['plugin.dir_url'];
219 }
220 );
221
222 Reg::registerService(
223 'plugin.rest_namespace',
224 static function () {
225 if ( ! isset( self::$cache['plugin.rest_namespace'] ) ) {
226 self::$cache['plugin.rest_namespace'] = 'sequra/v1';
227 }
228 return self::$cache['plugin.rest_namespace'];
229 }
230 );
231
232 Reg::registerService(
233 'woocommerce.data',
234 static function () {
235 if ( ! isset( self::$cache['woocommerce.data'] ) ) {
236 if ( ! function_exists( 'get_plugin_data' ) ) {
237 require_once ABSPATH . 'wp-admin/includes/plugin.php';
238 }
239 self::$cache['woocommerce.data'] = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php' );
240 }
241 return self::$cache['woocommerce.data'];
242 }
243 );
244
245 Reg::registerService(
246 'plugin.data',
247 static function () {
248 if ( ! isset( self::$cache['plugin.data'] ) ) {
249 if ( ! function_exists( 'get_plugin_data' ) ) {
250 require_once ABSPATH . 'wp-admin/includes/plugin.php';
251 }
252 $add_wc_headers = function ( $headers ) {
253 $headers['WC requires at least'] = 'WC requires at least';
254 return $headers;
255 };
256 add_filter( 'extra_plugin_headers', $add_wc_headers );
257 $data = get_plugin_data( Reg::getService( 'plugin.file_path' ) );
258 remove_filter( 'extra_plugin_headers', $add_wc_headers );
259 $data['RequiresWC'] = $data['WC requires at least'];
260 unset( $data['WC requires at least'] );
261
262 self::$cache['plugin.data'] = $data;
263 }
264 return self::$cache['plugin.data'];
265 }
266 );
267
268 Reg::registerService(
269 'environment.data',
270 static function () {
271 if ( ! isset( self::$cache['environment.data'] ) ) {
272 /**
273 * Database instance.
274 *
275 * @var \wpdb $wpdb
276 */
277 $wpdb = Reg::getService( \wpdb::class );
278
279 self::$cache['environment.data'] = array(
280 'php_version' => phpversion(),
281 'php_os' => PHP_OS,
282 'uname' => php_uname(),
283 'db_name' => false === strpos( strtolower( $wpdb->db_server_info() ), 'mariadb' ) ? 'mysql' : 'mariadb',
284 'db_version' => $wpdb->db_version() ?? '',
285 );
286 }
287 return self::$cache['environment.data'];
288 }
289 );
290
291 Reg::registerService(
292 'plugin.templates_path',
293 static function () {
294 if ( ! isset( self::$cache['plugin.templates_path'] ) ) {
295 self::$cache['plugin.templates_path'] = Reg::getService( 'plugin.dir_path' ) . 'templates/';
296 }
297 return self::$cache['plugin.templates_path'];
298 }
299 );
300 Reg::registerService(
301 'plugin.assets_path',
302 static function () {
303 if ( ! isset( self::$cache['plugin.assets_path'] ) ) {
304 self::$cache['plugin.assets_path'] = Reg::getService( 'plugin.dir_path' ) . 'assets';
305 }
306 return self::$cache['plugin.assets_path'];
307 }
308 );
309 Reg::registerService(
310 'plugin.assets_url',
311 static function () {
312 if ( ! isset( self::$cache['plugin.assets_url'] ) ) {
313 self::$cache['plugin.assets_url'] = untrailingslashit( Reg::getService( 'plugin.dir_url' ) ) . '/assets';
314 }
315 return self::$cache['plugin.assets_url'];
316 }
317 );
318 }
319
320 /**
321 * Initializes services and utilities.
322 */
323 protected static function initServices(): void {
324 parent::initServices();
325
326 // Core Default.
327 Reg::registerService(
328 LoggerConfiguration::class,
329 static function () {
330 if ( ! isset( self::$cache[ LoggerConfiguration::class ] ) ) {
331 $loggerConfig = LoggerConfiguration::getInstance();
332 if ( ! $loggerConfig->isDefaultLoggerEnabled() ) {
333 $loggerConfig->setIsDefaultLoggerEnabled( false );
334 }
335 self::$cache[ LoggerConfiguration::class ] = $loggerConfig;
336 }
337 return self::$cache[ LoggerConfiguration::class ];
338 }
339 );
340
341 // Core Extension.
342 Reg::registerService(
343 Order_Status_Settings_Service::class,
344 static function () {
345 if ( ! isset( self::$cache[ Order_Status_Settings_Service::class ] ) ) {
346 self::$cache[ Order_Status_Settings_Service::class ] = new Order_Status_Settings_Service(
347 Reg::getService( OrderStatusSettingsRepositoryInterface::class ),
348 Reg::getService( ShopOrderStatusesServiceInterface::class )
349 );
350 }
351 return self::$cache[ Order_Status_Settings_Service::class ];
352 }
353 );
354 Reg::registerService(
355 OrderStatusSettingsService::class,
356 static function () {
357 return Reg::getService( Order_Status_Settings_Service::class );
358 }
359 );
360 Reg::registerService(
361 Configuration::class,
362 static function () {
363 if ( ! isset( self::$cache[ Configuration::class ] ) ) {
364 self::$cache[ Configuration::class ] = Configuration::getInstance();
365 }
366 return self::$cache[ Configuration::class ];
367 }
368 );
369 Reg::registerService(
370 \SeQura\Core\Infrastructure\Configuration\Configuration::CLASS_NAME,
371 static function () {
372 return Reg::getService( Configuration::class );
373 }
374 );
375 Reg::registerService(
376 Interface_Create_Order_Request_Builder::class,
377 static function () {
378 if ( ! isset( self::$cache[ Interface_Create_Order_Request_Builder::class ] ) ) {
379 self::$cache[ Interface_Create_Order_Request_Builder::class ] = new Create_Order_Request_Builder(
380 Reg::getService( Interface_Payment_Service::class ),
381 Reg::getService( Interface_Cart_Service::class ),
382 Reg::getService( Configuration::class ),
383 Reg::getService( Interface_Product_Service::class ),
384 Reg::getService( Interface_Order_Service::class ),
385 Reg::getService( Interface_I18n::class ),
386 Reg::getService( Interface_Shopper_Service::class ),
387 Reg::getService( Interface_Logger_Service::class )
388 );
389 }
390 return self::$cache[ Interface_Create_Order_Request_Builder::class ];
391 }
392 );
393 Reg::registerService(
394 AbstractItemFactory::class,
395 static function () {
396 if ( ! isset( self::$cache[ AbstractItemFactory::class ] ) ) {
397 self::$cache[ AbstractItemFactory::class ] = new Item_Factory();
398 }
399 return self::$cache[ AbstractItemFactory::class ];
400 }
401 );
402
403 // Core Implementation.
404 Reg::registerService(
405 EncryptorInterface::class,
406 static function () {
407 if ( ! isset( self::$cache[ EncryptorInterface::class ] ) ) {
408 self::$cache[ EncryptorInterface::class ] = new Encryptor();
409 }
410 return self::$cache[ EncryptorInterface::class ];
411 }
412 );
413 Reg::registerService(
414 DisconnectServiceInterface::class,
415 static function () {
416 if ( ! isset( self::$cache[ DisconnectServiceInterface::class ] ) ) {
417 self::$cache[ DisconnectServiceInterface::class ] = new Disconnect_Service(
418 array(
419 RepositoryRegistry::getRepository( ConnectionData::class ),
420 RepositoryRegistry::getRepository( StatisticalData::class ),
421 RepositoryRegistry::getRepository( SendReport::class ),
422 RepositoryRegistry::getRepository( QueueItem::class ),
423 //phpcs:ignore
424 // RepositoryRegistry::getRepository( SeQuraOrder::class ),
425 )
426 );
427 }
428 return self::$cache[ DisconnectServiceInterface::class ];
429 }
430 );
431 Reg::registerService(
432 OrderReportServiceInterface::class,
433 static function () {
434 if ( ! isset( self::$cache[ OrderReportServiceInterface::class ] ) ) {
435 self::$cache[ OrderReportServiceInterface::class ] = new Order_Report_Service(
436 Reg::getService( Configuration::CLASS_NAME ),
437 Reg::getService( Interface_Pricing_Service::class ),
438 Reg::getService( Interface_Cart_Service::class ),
439 Reg::getService( Interface_Order_Service::class ),
440 Reg::getService( Interface_I18n::class )
441 );
442 }
443 return self::$cache[ OrderReportServiceInterface::class ];
444 }
445 );
446
447
448 Reg::registerService(
449 Serializer::class,
450 static function () {
451 if ( ! isset( self::$cache[ Serializer::class ] ) ) {
452 self::$cache[ Serializer::class ] = new JsonSerializer();
453 }
454 return self::$cache[ Serializer::class ];
455 }
456 );
457 Reg::registerService(
458 SellingCountriesServiceInterface::class,
459 static function () {
460 if ( ! isset( self::$cache[ SellingCountriesServiceInterface::class ] ) ) {
461 self::$cache[ SellingCountriesServiceInterface::class ] = new Selling_Countries_Service();
462 }
463 return self::$cache[ SellingCountriesServiceInterface::class ];
464 }
465 );
466 Reg::registerService(
467 StoreServiceInterface::class,
468 static function () {
469 if ( ! isset( self::$cache[ StoreServiceInterface::class ] ) ) {
470 self::$cache[ StoreServiceInterface::class ] = new Store_Service();
471 }
472 return self::$cache[ StoreServiceInterface::class ];
473 }
474 );
475 Reg::registerService(
476 VersionServiceInterface::class,
477 static function () {
478 if ( ! isset( self::$cache[ VersionServiceInterface::class ] ) ) {
479 self::$cache[ VersionServiceInterface::class ] = new Version_Service(
480 Reg::getService( 'plugin.data' )['Version']
481 );
482 }
483 return self::$cache[ VersionServiceInterface::class ];
484 }
485 );
486 Reg::registerService(
487 CategoryServiceInterface::class,
488 static function () {
489 if ( ! isset( self::$cache[ CategoryServiceInterface::class ] ) ) {
490 self::$cache[ CategoryServiceInterface::class ] = new Category_Service();
491 }
492 return self::$cache[ CategoryServiceInterface::class ];
493 }
494 );
495 Reg::registerService(
496 ShopOrderStatusesServiceInterface::class,
497 static function () {
498 if ( ! isset( self::$cache[ ShopOrderStatusesServiceInterface::class ] ) ) {
499 self::$cache[ ShopOrderStatusesServiceInterface::class ] = new Shop_Order_Status_Service();
500 }
501 return self::$cache[ ShopOrderStatusesServiceInterface::class ];
502 }
503 );
504 Reg::registerService(
505 ShopLoggerAdapter::CLASS_NAME,
506 static function () {
507 if ( ! isset( self::$cache[ ShopLoggerAdapter::CLASS_NAME ] ) ) {
508 self::$cache[ ShopLoggerAdapter::CLASS_NAME ] = new Shop_Logger_Adapter();
509 }
510 return self::$cache[ ShopLoggerAdapter::CLASS_NAME ];
511 }
512 );
513 Reg::registerService(
514 DefaultLoggerAdapter::CLASS_NAME,
515 static function () {
516 if ( ! isset( self::$cache[ DefaultLoggerAdapter::CLASS_NAME ] ) ) {
517 self::$cache[ DefaultLoggerAdapter::CLASS_NAME ] = new Default_Logger_Adapter(
518 Reg::getService( Interface_Log_File::class ),
519 Reg::getService( TimeProvider::CLASS_NAME )
520 );
521 }
522 return self::$cache[ DefaultLoggerAdapter::CLASS_NAME ];
523 }
524 );
525
526 // Plugin services.
527 Reg::registerService(
528 Interface_Log_File::class,
529 static function () {
530 if ( ! isset( self::$cache[ Interface_Log_File::class ] ) ) {
531 self::$cache[ Interface_Log_File::class ] = new Log_File(
532 Reg::getService( 'plugin.log_file_path' )
533 );
534 }
535 return self::$cache[ Interface_Log_File::class ];
536 }
537 );
538 Reg::registerService(
539 Interface_Migration_Manager::class,
540 static function () {
541 if ( ! isset( self::$cache[ Interface_Migration_Manager::class ] ) ) {
542 self::$cache[ Interface_Migration_Manager::class ] = new Migration_Manager(
543 Reg::getService( 'plugin.basename' ),
544 Reg::getService( Configuration::CLASS_NAME ),
545 Reg::getService( 'plugin.data' )['Version'],
546 array(
547 new Migration_Install_300(
548 Reg::getService( \wpdb::class ),
549 Reg::getService( Configuration::CLASS_NAME )
550 ),
551 )
552 );
553 }
554 return self::$cache[ Interface_Migration_Manager::class ];
555 }
556 );
557 Reg::registerService(
558 Interface_I18n::class,
559 static function () {
560 if ( ! isset( self::$cache[ Interface_I18n::class ] ) ) {
561 self::$cache[ Interface_I18n::class ] = new I18n();
562 }
563 return self::$cache[ Interface_I18n::class ];
564 }
565 );
566 Reg::registerService(
567 Interface_Regex::class,
568 static function () {
569 if ( ! isset( self::$cache[ Interface_Regex::class ] ) ) {
570 self::$cache[ Interface_Regex::class ] = new Regex();
571 }
572 return self::$cache[ Interface_Regex::class ];
573 }
574 );
575 Reg::registerService(
576 Interface_Report_Service::class,
577 static function () {
578 if ( ! isset( self::$cache[ Interface_Report_Service::class ] ) ) {
579 self::$cache[ Interface_Report_Service::class ] = new Report_Service(
580 Reg::getService( Configuration::class ),
581 Reg::getService( StoreService::class ),
582 Reg::getService( ShopOrderService::class ),
583 Reg::getService( StatisticalDataRepositoryInterface::class ),
584 Reg::getService( CountryConfigurationRepositoryInterface::class ),
585 Reg::getService( Interface_Order_Service::class ),
586 Reg::getService( StoreContext::class )
587 );
588 }
589 return self::$cache[ Interface_Report_Service::class ];
590 }
591 );
592 Reg::registerService(
593 Interface_Logger_Service::class,
594 static function () {
595 if ( ! isset( self::$cache[ Interface_Logger_Service::class ] ) ) {
596 self::$cache[ Interface_Logger_Service::class ] = new Logger_Service(
597 Reg::getService( LoggerConfiguration::class ),
598 Reg::getService( Interface_Log_File::class )
599 );
600 }
601 return self::$cache[ Interface_Logger_Service::class ];
602 }
603 );
604 Reg::registerService(
605 Interface_Payment_Service::class,
606 static function () {
607 if ( ! isset( self::$cache[ Interface_Payment_Service::class ] ) ) {
608 self::$cache[ Interface_Payment_Service::class ] = new Payment_Service(
609 Reg::getService( Configuration::class ),
610 Reg::getService( Interface_I18n::class )
611 );
612 }
613 return self::$cache[ Interface_Payment_Service::class ];
614 }
615 );
616 Reg::registerService(
617 Sequra_Payment_Gateway_Block_Support::class,
618 static function () {
619 if ( ! isset( self::$cache[ Sequra_Payment_Gateway_Block_Support::class ] ) ) {
620 self::$cache[ Sequra_Payment_Gateway_Block_Support::class ] = new Sequra_Payment_Gateway_Block_Support(
621 Reg::getService( 'plugin.assets_path' ),
622 Reg::getService( 'plugin.assets_url' ),
623 Reg::getService( 'plugin.data' )['Version']
624 );
625 }
626 return self::$cache[ Sequra_Payment_Gateway_Block_Support::class ];
627 }
628 );
629 Reg::registerService(
630 Interface_Pricing_Service::class,
631 static function () {
632 if ( ! isset( self::$cache[ Interface_Pricing_Service::class ] ) ) {
633 self::$cache[ Interface_Pricing_Service::class ] = new Pricing_Service();
634 }
635 return self::$cache[ Interface_Pricing_Service::class ];
636 }
637 );
638 Reg::registerService(
639 Interface_Order_Service::class,
640 static function () {
641 if ( ! isset( self::$cache[ Interface_Order_Service::class ] ) ) {
642 self::$cache[ Interface_Order_Service::class ] = new Order_Service(
643 Reg::getService( Interface_Payment_Service::class ),
644 Reg::getService( Interface_Pricing_Service::class ),
645 Reg::getService( OrderStatusSettingsService::class ),
646 Reg::getService( Configuration::class ),
647 Reg::getService( Interface_Cart_Service::class ),
648 Reg::getService( StoreContext::class )
649 );
650 }
651 return self::$cache[ Interface_Order_Service::class ];
652 }
653 );
654 Reg::registerService(
655 Interface_Cart_Service::class,
656 static function () {
657 if ( ! isset( self::$cache[ Interface_Cart_Service::class ] ) ) {
658 self::$cache[ Interface_Cart_Service::class ] = new Cart_Service(
659 Reg::getService( Interface_Product_Service::class ),
660 Reg::getService( Configuration::class ),
661 Reg::getService( Interface_Pricing_Service::class ),
662 Reg::getService( Interface_Logger_Service::class )
663 );
664 }
665 return self::$cache[ Interface_Cart_Service::class ];
666 }
667 );
668 Reg::registerService(
669 Interface_Product_Service::class,
670 static function () {
671 if ( ! isset( self::$cache[ Interface_Product_Service::class ] ) ) {
672 self::$cache[ Interface_Product_Service::class ] = new Product_Service(
673 Reg::getService( Configuration::class ),
674 Reg::getService( Interface_Pricing_Service::class ),
675 Reg::getService( Interface_Regex::class )
676 );
677 }
678 return self::$cache[ Interface_Product_Service::class ];
679 }
680 );
681 Reg::registerService(
682 Interface_Shopper_Service::class,
683 static function () {
684 if ( ! isset( self::$cache[ Interface_Shopper_Service::class ] ) ) {
685 self::$cache[ Interface_Shopper_Service::class ] = new Shopper_Service();
686 }
687 return self::$cache[ Interface_Shopper_Service::class ];
688 }
689 );
690 Reg::registerService(
691 ShopOrderService::class,
692 static function () {
693 if ( ! isset( self::$cache[ ShopOrderService::class ] ) ) {
694 self::$cache[ ShopOrderService::class ] = new Shop_Order_Service(
695 Reg::getService( SeQuraOrderRepositoryInterface::class ),
696 Reg::getService( Interface_Logger_Service::class )
697 );
698 }
699 return self::$cache[ ShopOrderService::class ];
700 }
701 );
702 Reg::registerService(
703 Interface_Assets::class,
704 static function () {
705 if ( ! isset( self::$cache[ Interface_Assets::class ] ) ) {
706 self::$cache[ Interface_Assets::class ] = new Assets();
707 }
708 return self::$cache[ Interface_Assets::class ];
709 }
710 );
711 }
712
713 /**
714 * Initializes repositories.
715 */
716 protected static function initRepositories(): void {
717
718 Reg::registerService(
719 \wpdb::class,
720 static function () {
721 if ( ! isset( self::$cache[ \wpdb::class ] ) ) {
722 global $wpdb;
723 self::$cache[ \wpdb::class ] = $wpdb;
724 }
725 return self::$cache[ \wpdb::class ];
726 }
727 );
728
729 parent::initRepositories();
730
731 // Extend GeneralSettingsRepository.
732 Reg::registerService(
733 GeneralSettingsRepositoryInterface::class,
734 static function () {
735 return new General_Settings_Repository(
736 RepositoryRegistry::getRepository( GeneralSettings::getClassName() ),
737 Reg::getService( StoreContext::class )
738 );
739 }
740 );
741
742 // Extend WidgetSettingsRepository.
743 Reg::registerService(
744 WidgetSettingsRepositoryInterface::class,
745 static function () {
746 return new Widget_Settings_Repository(
747 RepositoryRegistry::getRepository( WidgetSettings::getClassName() ),
748 Reg::getService( StoreContext::class )
749 );
750 }
751 );
752
753 RepositoryRegistry::registerRepository( ConfigEntity::class, Entity_Repository::class );
754 RepositoryRegistry::registerRepository( QueueItem::class, Queue_Item_Repository::class );
755 RepositoryRegistry::registerRepository( Process::class, Entity_Repository::class );
756 RepositoryRegistry::registerRepository( ConnectionData::class, Entity_Repository::class );
757 RepositoryRegistry::registerRepository( OrderStatusSettings::class, Entity_Repository::class );
758 RepositoryRegistry::registerRepository( StatisticalData::class, Entity_Repository::class );
759 RepositoryRegistry::registerRepository( CountryConfiguration::class, Entity_Repository::class );
760 RepositoryRegistry::registerRepository( GeneralSettings::class, Entity_Repository::class );
761 RepositoryRegistry::registerRepository( SeQuraOrder::class, SeQura_Order_Repository::class );
762 RepositoryRegistry::registerRepository( WidgetSettings::class, Entity_Repository::class );
763 RepositoryRegistry::registerRepository( SendReport::class, Entity_Repository::class );
764 RepositoryRegistry::registerRepository( TransactionLog::class, Entity_Repository::class );
765 }
766
767 /**
768 * Initializes controllers.
769 */
770 protected static function initControllers(): void {
771 parent::initControllers();
772
773 // Extend GeneralSettingsController.
774 Reg::registerService(
775 GeneralSettingsController::class,
776 static function () {
777 return new General_Settings_Controller(
778 Reg::getService( GeneralSettingsService::class ),
779 Reg::getService( CategoryService::class )
780 );
781 }
782 );
783
784 // Extend PromotionalWidgetsController.
785 Reg::registerService(
786 PromotionalWidgetsController::class,
787 static function () {
788 return new Promotional_Widgets_Controller(
789 Reg::getService( WidgetSettingsService::class )
790 );
791 }
792 );
793
794 // Plugin controllers.
795 Reg::registerService(
796 Interface_I18n_Controller::class,
797 static function () {
798 if ( ! isset( self::$cache[ Interface_I18n_Controller::class ] ) ) {
799 $data = Reg::getService( 'plugin.data' );
800 $domain = $data['TextDomain'];
801 self::$cache[ Interface_I18n_Controller::class ] = new I18n_Controller(
802 $domain . $data['DomainPath'],
803 $domain,
804 Reg::getService( Interface_Logger_Service::class ),
805 Reg::getService( 'plugin.templates_path' )
806 );
807 }
808 return self::$cache[ Interface_I18n_Controller::class ];
809 }
810 );
811 Reg::registerService(
812 Interface_Assets_Controller::class,
813 static function () {
814 if ( ! isset( self::$cache[ Interface_Assets_Controller::class ] ) ) {
815 self::$cache[ Interface_Assets_Controller::class ] = new Assets_Controller(
816 Reg::getService( 'plugin.assets_url' ),
817 Reg::getService( 'plugin.assets_path' ),
818 Reg::getService( 'plugin.data' )['Version'],
819 Reg::getService( Interface_I18n::class ),
820 Reg::getService( Interface_Logger_Service::class ),
821 Reg::getService( 'plugin.templates_path' ),
822 Reg::getService( Configuration::class ),
823 Reg::getService( Interface_Assets::class ),
824 Reg::getService( Interface_Payment_Method_Service::class ),
825 Reg::getService( Interface_Regex::class )
826 );
827 }
828 return self::$cache[ Interface_Assets_Controller::class ];
829 }
830 );
831 Reg::registerService(
832 Interface_Settings_Controller::class,
833 static function () {
834 if ( ! isset( self::$cache[ Interface_Settings_Controller::class ] ) ) {
835 self::$cache[ Interface_Settings_Controller::class ] = new Settings_Controller(
836 Reg::getService( 'plugin.templates_path' ),
837 Reg::getService( Configuration::class ),
838 Reg::getService( Interface_Logger_Service::class ),
839 Reg::getService( 'plugin.basename' )
840 );
841 }
842 return self::$cache[ Interface_Settings_Controller::class ];
843 }
844 );
845 Reg::registerService(
846 Interface_Payment_Controller::class,
847 static function () {
848 if ( ! isset( self::$cache[ Interface_Payment_Controller::class ] ) ) {
849 self::$cache[ Interface_Payment_Controller::class ] = new Payment_Controller(
850 Reg::getService( Interface_Logger_Service::class ),
851 Reg::getService( 'plugin.templates_path' ),
852 Reg::getService( Interface_Order_Service::class )
853 );
854 }
855 return self::$cache[ Interface_Payment_Controller::class ];
856 }
857 );
858 Reg::registerService(
859 Interface_Product_Controller::class,
860 static function () {
861 if ( ! isset( self::$cache[ Interface_Product_Controller::class ] ) ) {
862 self::$cache[ Interface_Product_Controller::class ] = new Product_Controller(
863 Reg::getService( Interface_Logger_Service::class ),
864 Reg::getService( 'plugin.templates_path' ),
865 Reg::getService( Configuration::class ),
866 Reg::getService( Interface_Product_Service::class ),
867 Reg::getService( Interface_Payment_Service::class ),
868 Reg::getService( Interface_Payment_Method_Service::class ),
869 Reg::getService( Interface_I18n::class ),
870 Reg::getService( Interface_Regex::class )
871 );
872 }
873 return self::$cache[ Interface_Product_Controller::class ];
874 }
875 );
876 Reg::registerService(
877 Interface_Async_Process_Controller::class,
878 static function () {
879 if ( ! isset( self::$cache[ Interface_Async_Process_Controller::class ] ) ) {
880 self::$cache[ Interface_Async_Process_Controller::class ] = new Async_Process_Controller(
881 Reg::getService( Interface_Logger_Service::class ),
882 Reg::getService( 'plugin.templates_path' ),
883 Reg::getService( Interface_Report_Service::class )
884 );
885 }
886 return self::$cache[ Interface_Async_Process_Controller::class ];
887 }
888 );
889 Reg::registerService(
890 Interface_Order_Controller::class,
891 static function () {
892 if ( ! isset( self::$cache[ Interface_Order_Controller::class ] ) ) {
893 self::$cache[ Interface_Order_Controller::class ] = new Order_Controller(
894 Reg::getService( Interface_Logger_Service::class ),
895 Reg::getService( 'plugin.templates_path' ),
896 Reg::getService( Interface_Order_Service::class )
897 );
898 }
899 return self::$cache[ Interface_Order_Controller::class ];
900 }
901 );
902 Reg::registerService(
903 Onboarding_REST_Controller::class,
904 static function () {
905 if ( ! isset( self::$cache[ Onboarding_REST_Controller::class ] ) ) {
906 self::$cache[ Onboarding_REST_Controller::class ] = new Onboarding_REST_Controller(
907 Reg::getService( 'plugin.rest_namespace' ),
908 Reg::getService( Interface_Logger_Service::class )
909 );
910 }
911 return self::$cache[ Onboarding_REST_Controller::class ];
912 }
913 );
914 Reg::registerService(
915 Payment_REST_Controller::class,
916 static function () {
917 if ( ! isset( self::$cache[ Payment_REST_Controller::class ] ) ) {
918 self::$cache[ Payment_REST_Controller::class ] = new Payment_REST_Controller(
919 Reg::getService( 'plugin.rest_namespace' ),
920 Reg::getService( Interface_Logger_Service::class ),
921 Reg::getService( Interface_Payment_Method_Service::class )
922 );
923 }
924 return self::$cache[ Payment_REST_Controller::class ];
925 }
926 );
927 Reg::registerService(
928 General_Settings_REST_Controller::class,
929 static function () {
930 if ( ! isset( self::$cache[ General_Settings_REST_Controller::class ] ) ) {
931 self::$cache[ General_Settings_REST_Controller::class ] = new General_Settings_REST_Controller(
932 Reg::getService( 'plugin.rest_namespace' ),
933 Reg::getService( Interface_Logger_Service::class )
934 );
935 }
936 return self::$cache[ General_Settings_REST_Controller::class ];
937 }
938 );
939 Reg::registerService(
940 Log_REST_Controller::class,
941 static function () {
942 if ( ! isset( self::$cache[ Log_REST_Controller::class ] ) ) {
943 self::$cache[ Log_REST_Controller::class ] = new Log_REST_Controller(
944 Reg::getService( 'plugin.rest_namespace' ),
945 Reg::getService( Interface_Logger_Service::class )
946 );
947 }
948 return self::$cache[ Log_REST_Controller::class ];
949 }
950 );
951 Reg::registerService(
952 Interface_Payment_Method_Service::class,
953 static function () {
954 if ( ! isset( self::$cache[ Interface_Payment_Method_Service::class ] ) ) {
955 self::$cache[ Interface_Payment_Method_Service::class ] = new Payment_Method_Service(
956 Reg::getService( Configuration::class ),
957 Reg::getService( Interface_Create_Order_Request_Builder::class ),
958 Reg::getService( Interface_Order_Service::class ),
959 Reg::getService( Interface_Logger_Service::class )
960 );
961 }
962 return self::$cache[ Interface_Payment_Method_Service::class ];
963 }
964 );
965 }
966 }
967