You can create custom purgers by implementing the PurgerInterface
. This allows you to define your own logic for
handling purge requests. Once implemented, be sure to tag your custom purger with purgatory.purger
to make it
available for configuration.
Here’s an example of a custom purger for Cloudflare:
use Sofascore\PurgatoryBundle\Purger\PurgerInterface;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
#[AutoconfigureTag('purgatory.purger', ['alias' => 'cloudflare'])]
class CloudflarePurger implements PurgerInterface
{
public function purge(iterable $purgeRequests): void
{
// Your custom logic to send purge requests to Cloudflare
}
}
To enable your custom purger, update your configuration file with the alias you specified:
# config/packages/purgatory.yaml
purgatory:
purger: cloudflare
In this example, the alias cloudflare
is used to refer to the custom purger.