<?php
namespace App\EventListener;
use App\Event\ExternalIntegration\ExternalIntegrationEvent;
use FOS\HttpCacheBundle\CacheManager;
use Psr\Log\LoggerInterface;
class CacheManagerImportCompleteEventListener
{
public const INVALIDATION_TAGS = ['options', 'option-values', 'recruiters', 'vacancies'];
private LoggerInterface $logger;
private CacheManager $cacheManager;
public function __construct(LoggerInterface $logger, CacheManager $cacheManager)
{
$this->logger = $logger;
$this->cacheManager = $cacheManager;
}
public function onExternalIntergationImportCompleted(ExternalIntegrationEvent $event)
{
$this->cacheManager->invalidateTags(self::INVALIDATION_TAGS);
$this->logger->info(sprintf(
'Cleared http cache for the following tags "%s"',
implode(', ', self::INVALIDATION_TAGS)
));
}
}