cms
cms copied to clipboard
[4.x] Allow a class to be specified to generate extra static:warm routes
When using static:warm
the command already cleverly works out any urls to hit from the repositories and basic Route::statamic
routes.
However if you have a Route::statamic that has dynamic elements, eg Route::statamic('/artist/{artistSlug}/{portfolioType}')
then it doesn't know the URLs to hit.
This PR adds the concept of an extra uri generator to the static:warm
command, allow you to specify a class with a handle method that returns a collection of (absolute or relative) urls to hit, e.g.
<?php
namespace App\Caching;
class StaticWarmExtras
{
public function handle()
{
return collect(['/path/to/some/page']);
}
}
This class can be defined in statamic.static_caching.warm_extra_routes_generator
eg
'warm_extra_routes_generator' => \App\Caching\StaticWarmExtras::Class,