1 | <?php |
||
13 | class ResponseCacheServiceProvider extends ServiceProvider |
||
14 | { |
||
15 | public function boot() |
||
16 | { |
||
17 | $this->publishes([ |
||
18 | __DIR__.'/../config/responsecache.php' => config_path('responsecache.php'), |
||
19 | ], 'config'); |
||
20 | |||
21 | $this->app->bind(CacheProfile::class, function (Container $app) { |
||
22 | return $app->make(config('responsecache.cache_profile')); |
||
23 | }); |
||
24 | |||
25 | $this->app->bind(RequestHasher::class, function (Container $app) { |
||
26 | return $app->make(config('responsecache.hasher')); |
||
27 | }); |
||
28 | |||
29 | $this->app->bind(Serializer::class, function (Container $app) { |
||
30 | return $app->make(config('responsecache.serializer')); |
||
31 | }); |
||
32 | |||
33 | $this->app->when(ResponseCacheRepository::class) |
||
34 | ->needs(Repository::class) |
||
35 | ->give(function (): Repository { |
||
36 | $repository = app('cache')->store(config('responsecache.cache_store')); |
||
37 | if (! empty(config('responsecache.cache_tag'))) { |
||
38 | return $repository->tags(config('responsecache.cache_tag')); |
||
39 | } |
||
40 | |||
41 | return $repository; |
||
42 | }); |
||
43 | |||
44 | $this->app->singleton('responsecache', ResponseCache::class); |
||
45 | |||
46 | if ($this->app->runningInConsole()) { |
||
47 | $this->commands([ |
||
48 | ClearCommand::class, |
||
49 | ]); |
||
50 | } |
||
51 | } |
||
52 | |||
53 | public function register() |
||
57 | } |
||
58 |