CacheService.php
2 weeks ago
CacheServiceProvider.php
2 weeks ago
DoNotCachePageService.php
2 weeks ago
LiteSpeedCacheService.php
4 months ago
W3TotalCacheService.php
4 months ago
WpFastestCacheService.php
4 months ago
CacheServiceProvider.php
58 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SureCart\WordPress\Cache; |
| 4 | |
| 5 | use SureCartCore\ServiceProviders\ServiceProviderInterface; |
| 6 | |
| 7 | /** |
| 8 | * Cache Service Provider. |
| 9 | */ |
| 10 | class CacheServiceProvider implements ServiceProviderInterface { |
| 11 | /** |
| 12 | * Holds the service container. |
| 13 | * |
| 14 | * @var \Pimple\Container |
| 15 | */ |
| 16 | protected $container; |
| 17 | |
| 18 | /** |
| 19 | * Register all dependencies in the container. |
| 20 | * |
| 21 | * @param \Pimple\Container $container Service Container. |
| 22 | */ |
| 23 | public function register( $container ) { |
| 24 | $container['surecart.litespeed_cache'] = function () { |
| 25 | return new LiteSpeedCacheService(); |
| 26 | }; |
| 27 | $container['surecart.wpfastest_cache'] = function () { |
| 28 | return new WpFastestCacheService(); |
| 29 | }; |
| 30 | $container['surecart.w3total_cache'] = function () { |
| 31 | return new W3TotalCacheService(); |
| 32 | }; |
| 33 | $container['surecart.donotcache_page'] = function () { |
| 34 | return new DoNotCachePageService(); |
| 35 | }; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Bootstrap any services if needed. |
| 40 | * |
| 41 | * @param \Pimple\Container $container Service Container. |
| 42 | */ |
| 43 | public function bootstrap( $container ) { |
| 44 | // Bootstrap cache services on 'plugins_loaded' to ensure all plugins |
| 45 | // are loaded before we check for active cache plugins. |
| 46 | add_action( |
| 47 | 'plugins_loaded', |
| 48 | function () use ( $container ) { |
| 49 | $container['surecart.litespeed_cache']->bootstrap(); |
| 50 | $container['surecart.wpfastest_cache']->bootstrap(); |
| 51 | $container['surecart.w3total_cache']->bootstrap(); |
| 52 | $container['surecart.donotcache_page']->bootstrap(); |
| 53 | }, |
| 54 | 999 // Late priority to ensure it runs after most plugins have loaded. |
| 55 | ); |
| 56 | } |
| 57 | } |
| 58 |