PluginProbe
seQura / 3.0.7
seQura v3.0.7
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.7, at src/class-bootstrap.php

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