BlockTemplatesService.php
1 year ago
CollectionTemplateService.php
1 year ago
TemplatesService.php
1 year ago
TemplatesServiceProvider.php
1 year ago
UpsellTemplatesService.php
1 year ago
TemplatesServiceProvider.php
79 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\WordPress\Templates; |
| 4 | |
| 5 | use SureCartCore\ServiceProviders\ServiceProviderInterface; |
| 6 | |
| 7 | /** |
| 8 | * Templates service provider. |
| 9 | */ |
| 10 | class TemplatesServiceProvider implements ServiceProviderInterface { |
| 11 | /** |
| 12 | * Register all dependencies in the IoC container. |
| 13 | * |
| 14 | * @param \Pimple\Container $container Service container. |
| 15 | * @return void |
| 16 | */ |
| 17 | public function register( $container ) { |
| 18 | $container['surecart.templates.page'] = function ( $c ) { |
| 19 | return new TemplatesService( |
| 20 | $c, |
| 21 | [ |
| 22 | 'pages/template-surecart-blank.php' => esc_html__( 'SureCart', 'surecart' ), |
| 23 | 'pages/template-surecart-dashboard.php' => esc_html__( 'SureCart Customer Dashboard', 'surecart' ), |
| 24 | ], |
| 25 | 'page' |
| 26 | ); |
| 27 | }; |
| 28 | |
| 29 | $container['surecart.templates.product'] = function ( $c ) { |
| 30 | return new TemplatesService( |
| 31 | $c, |
| 32 | [ |
| 33 | 'pages/template-surecart-product.php' => esc_html__( 'SureCart Layout', 'surecart' ), |
| 34 | ], |
| 35 | 'sc_product' |
| 36 | ); |
| 37 | }; |
| 38 | |
| 39 | $container['surecart.templates.collection'] = function ( $c ) { |
| 40 | return new CollectionTemplateService( |
| 41 | [ |
| 42 | 'pages/template-surecart-collection.php' => esc_html__( 'SureCart Layout', 'surecart' ), |
| 43 | ] |
| 44 | ); |
| 45 | }; |
| 46 | |
| 47 | $container['surecart.templates.upsell'] = function ( $c ) { |
| 48 | return new UpsellTemplatesService( |
| 49 | $c, |
| 50 | [ |
| 51 | 'pages/template-surecart-blank.php' => esc_html__( 'SureCart Layout', 'surecart' ), |
| 52 | ], |
| 53 | ); |
| 54 | }; |
| 55 | |
| 56 | $container['surecart.templates.blocks'] = function ( $c ) { |
| 57 | $root_path = trailingslashit( $c[ SURECART_CONFIG_KEY ]['app_core']['path'] ) . '/templates/'; |
| 58 | return new BlockTemplatesService( $root_path . 'templates', $root_path . 'parts' ); |
| 59 | }; |
| 60 | |
| 61 | $app = $container[ SURECART_APPLICATION_KEY ]; |
| 62 | $app->alias( 'templates', 'surecart.templates' ); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Bootstrap the service. |
| 67 | * |
| 68 | * @param \Pimple\Container $container Service container. |
| 69 | * @return void |
| 70 | */ |
| 71 | public function bootstrap( $container ) { |
| 72 | $container['surecart.templates.page']->bootstrap(); |
| 73 | $container['surecart.templates.product']->bootstrap(); |
| 74 | $container['surecart.templates.collection']->bootstrap(); |
| 75 | $container['surecart.templates.upsell']->bootstrap(); |
| 76 | $container['surecart.templates.blocks']->bootstrap(); |
| 77 | } |
| 78 | } |
| 79 |