Skip to content

Commit 24c6c7f

Browse files
committed
Register all cloudfront strategies
Instead of just loading the strategy named cloudfront, load all strategies using the cloudfront driver. Also use getConfig function to pull config so the CloudfrontCacher has all the required config.
1 parent a51099c commit 24c6c7f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/ServiceProvider.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ public function boot()
1414

1515
public function register()
1616
{
17-
$config = config('statamic.static_caching.strategies.cloudfront');
17+
$cloudfrontStrategies = collect(config('statamic.static_caching.strategies'));
1818

19-
if ($config !== null) {
20-
$this->app[StaticCacheManager::class]->extend('cloudfront', function () use ($config) {
21-
return new CloudfrontCacher($this->app[Repository::class], $config);
19+
$cloudfrontStrategies->where('driver', 'cloudfront')->each(function ($item, $strategy) {
20+
$this->app[StaticCacheManager::class]->extend($strategy, function () use ($strategy) {
21+
return new CloudfrontCacher($this->app[Repository::class], $this->getConfig($strategy));
2222
});
23+
});
2324

24-
$router = $this->app['router'];
25-
$router->pushMiddlewareToGroup('web', Middleware\CacheControlHeader::class);
26-
}
25+
$router = $this->app['router'];
26+
$router->pushMiddlewareToGroup('web', Middleware\CacheControlHeader::class);
2727
}
2828
}

0 commit comments

Comments
 (0)