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