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

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

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