AssetsService.php
2 years ago
AssetsServiceProvider.php
3 years ago
BlockAssetsLoadService.php
3 years ago
PreloadService.php
3 years ago
ScriptsService.php
2 years ago
StylesService.php
3 years ago
AssetsServiceProvider.php
49 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\WordPress\Assets; |
| 4 | |
| 5 | use SureCartCore\ServiceProviders\ServiceProviderInterface; |
| 6 | |
| 7 | /** |
| 8 | * Register and enqueues assets. |
| 9 | */ |
| 10 | class AssetsServiceProvider implements ServiceProviderInterface { |
| 11 | /** |
| 12 | * Holds the service container |
| 13 | * |
| 14 | * @var \Pimple\Container |
| 15 | */ |
| 16 | protected $container; |
| 17 | |
| 18 | /** |
| 19 | * {@inheritDoc} |
| 20 | * |
| 21 | * @param \Pimple\Container $container Service Container. |
| 22 | */ |
| 23 | public function register( $container ) { |
| 24 | $container['surecart.assets'] = function () use ( $container ) { |
| 25 | return new AssetsService( new BlockAssetsLoadService(), new ScriptsService( $container ), new StylesService( $container ), $container ); |
| 26 | }; |
| 27 | |
| 28 | $container['surecart.assets.preload'] = function() use ( $container ) { |
| 29 | return new PreloadService( trailingslashit( $container[ SURECART_CONFIG_KEY ]['app_core']['path'] ) . 'dist/components/stats.json' ); |
| 30 | }; |
| 31 | |
| 32 | $app = $container[ SURECART_APPLICATION_KEY ]; |
| 33 | |
| 34 | $app->alias( 'assets', 'surecart.assets' ); |
| 35 | $app->alias( 'preload', 'surecart.assets.preload' ); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * {@inheritDoc} |
| 40 | * |
| 41 | * @param \Pimple\Container $container Service Container. |
| 42 | */ |
| 43 | public function bootstrap( $container ) { |
| 44 | $this->container = $container; |
| 45 | $container['surecart.assets']->bootstrap(); |
| 46 | $container['surecart.assets.preload']->bootstrap(); |
| 47 | } |
| 48 | } |
| 49 |