Admin
2 months ago
Assets
2 weeks ago
CLI
2 years ago
Cache
2 weeks ago
Pages
10 months ago
PostTypes
2 months ago
Posts
1 year ago
Shortcodes
1 month ago
Taxonomies
1 year ago
Templates
1 year ago
Users
2 months ago
ActionsService.php
3 years ago
CompatibilityService.php
4 months ago
CurrencyService.php
4 months ago
GoogleMapApiService.php
2 months ago
HealthService.php
2 months ago
LineItemStateService.php
2 years ago
PluginActionLinksService.php
1 year ago
PluginService.php
1 year ago
PluginServiceProvider.php
1 year ago
RecaptchaValidationService.php
2 years ago
StateService.php
7 months ago
ThemeService.php
4 months ago
ThemeServiceProvider.php
7 months ago
TranslationsServiceProvider.php
3 months ago
UpgradeNoticeService.php
1 year ago
PluginServiceProvider.php
90 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\WordPress; |
| 4 | |
| 5 | use SureCart\WordPress\PluginService; |
| 6 | use SureCart\WordPress\UpgradeNoticeService; |
| 7 | use SureCart\WordPress\PluginActionLinksService; |
| 8 | use SureCartCore\ServiceProviders\ServiceProviderInterface; |
| 9 | |
| 10 | /** |
| 11 | * Register plugin options. |
| 12 | */ |
| 13 | class PluginServiceProvider implements ServiceProviderInterface { |
| 14 | /** |
| 15 | * Register all dependencies in the IoC container. |
| 16 | * |
| 17 | * @param \Pimple\Container $container Service container. |
| 18 | * @return void |
| 19 | */ |
| 20 | public function register( $container ) { |
| 21 | $container['surecart.plugin'] = function ( $c ) { |
| 22 | return new PluginService( $c[ SURECART_APPLICATION_KEY ] ); |
| 23 | }; |
| 24 | |
| 25 | $container['surecart.upgrade.notice'] = function ( $c ) { |
| 26 | return new UpgradeNoticeService( $c[ SURECART_APPLICATION_KEY ] ); |
| 27 | }; |
| 28 | |
| 29 | $container['surecart.plugin.action.links'] = function ( $c ) { |
| 30 | return new PluginActionLinksService( $c[ SURECART_APPLICATION_KEY ] ); |
| 31 | }; |
| 32 | |
| 33 | $container['surecart.actions'] = function () { |
| 34 | return new ActionsService(); |
| 35 | }; |
| 36 | |
| 37 | $container['surecart.config.setting'] = function ( $c ) { |
| 38 | return json_decode( json_encode( $c[ SURECART_CONFIG_KEY ] ) ); |
| 39 | }; |
| 40 | |
| 41 | $container['surecart.health'] = function () { |
| 42 | return new HealthService(); |
| 43 | }; |
| 44 | |
| 45 | $container['surecart.compatibility'] = function () { |
| 46 | return new CompatibilityService(); |
| 47 | }; |
| 48 | |
| 49 | // singleton. |
| 50 | $currency_service = new CurrencyService(); |
| 51 | $container['surecart.currency'] = function () use ( $currency_service ) { |
| 52 | return $currency_service; |
| 53 | }; |
| 54 | |
| 55 | $singleton = new StateService( [] ); |
| 56 | $container['surecart.initialstate'] = function () use ( $singleton ) { |
| 57 | return $singleton; |
| 58 | }; |
| 59 | |
| 60 | $app = $container[ SURECART_APPLICATION_KEY ]; |
| 61 | $app->alias( 'plugin', 'surecart.plugin' ); |
| 62 | $app->alias( 'actions', 'surecart.actions' ); |
| 63 | $app->alias( 'config', 'surecart.config.setting' ); |
| 64 | $app->alias( 'healthCheck', 'surecart.health' ); |
| 65 | $app->alias( 'state', 'surecart.initialstate' ); |
| 66 | $app->alias( 'currency', 'surecart.currency' ); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * {@inheritDoc} |
| 71 | */ |
| 72 | public function bootstrap( $container ) { |
| 73 | $container['surecart.health']->bootstrap(); |
| 74 | $container['surecart.compatibility']->bootstrap(); |
| 75 | $container['surecart.initialstate']->bootstrap(); |
| 76 | $container['surecart.upgrade.notice']->bootstrap(); |
| 77 | $container['surecart.plugin.action.links']->bootstrap(); |
| 78 | $container['surecart.currency']->bootstrap(); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Load textdomain. |
| 83 | * |
| 84 | * @return void |
| 85 | */ |
| 86 | public function loadTextdomain() { |
| 87 | load_plugin_textdomain( 'surecart', false, basename( dirname( SURECART_PLUGIN_FILE ) ) . DIRECTORY_SEPARATOR . 'languages' ); |
| 88 | } |
| 89 | } |
| 90 |