|
4 | 4 |
|
5 | 5 | namespace TailwindMerge\Laravel; |
6 | 6 |
|
| 7 | +use Illuminate\Support\Facades\Cache; |
7 | 8 | use Illuminate\Support\ServiceProvider as BaseServiceProvider; |
8 | 9 | use Illuminate\View\Compilers\BladeCompiler; |
9 | 10 | use Illuminate\View\ComponentAttributeBag; |
| 11 | +use Psr\SimpleCache\CacheInterface; |
10 | 12 | use TailwindMerge\Contracts\TailwindMergeContract; |
11 | 13 | use TailwindMerge\TailwindMerge; |
12 | 14 |
|
13 | 15 | class TailwindMergeServiceProvider extends BaseServiceProvider |
14 | 16 | { |
15 | 17 | public function register(): void |
16 | 18 | { |
17 | | - $this->app->singleton(TailwindMergeContract::class, static fn (): TailwindMerge => TailwindMerge::factory() |
| 19 | + $this->app->singleton(TailwindMergeContract::class, fn (): TailwindMerge => TailwindMerge::factory() |
18 | 20 | ->withConfiguration(config('tailwind-merge', [])) |
19 | | - ->withCache(app('cache')->store()) // @phpstan-ignore-line |
| 21 | + ->withCache($this->getCacheStore()) |
20 | 22 | ->make()); |
21 | 23 |
|
22 | 24 | $this->app->alias(TailwindMergeContract::class, 'tailwind-merge'); |
@@ -90,4 +92,16 @@ public function provides(): array |
90 | 92 | 'tailwind-merge', |
91 | 93 | ]; |
92 | 94 | } |
| 95 | + |
| 96 | + protected function getCacheStore(): CacheInterface |
| 97 | + { |
| 98 | + /** @var string $storage */ |
| 99 | + $storage = config('tailwind-merge.cache.store', 'default'); |
| 100 | + |
| 101 | + if ($storage === 'default') { |
| 102 | + return Cache::store(); |
| 103 | + } |
| 104 | + |
| 105 | + return Cache::store($storage); |
| 106 | + } |
93 | 107 | } |
0 commit comments