src/EventListener/CacheManagerImportCompleteEventListener.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use App\Event\ExternalIntegration\ExternalIntegrationEvent;
  4. use FOS\HttpCacheBundle\CacheManager;
  5. use Psr\Log\LoggerInterface;
  6. class CacheManagerImportCompleteEventListener
  7. {
  8.     public const INVALIDATION_TAGS = ['options''option-values''recruiters''vacancies'];
  9.     private LoggerInterface $logger;
  10.     private CacheManager $cacheManager;
  11.     public function __construct(LoggerInterface $loggerCacheManager $cacheManager)
  12.     {
  13.         $this->logger $logger;
  14.         $this->cacheManager $cacheManager;
  15.     }
  16.     public function onExternalIntergationImportCompleted(ExternalIntegrationEvent $event)
  17.     {
  18.         $this->cacheManager->invalidateTags(self::INVALIDATION_TAGS);
  19.         $this->logger->info(sprintf(
  20.             'Cleared http cache for the following tags "%s"',
  21.             implode(', 'self::INVALIDATION_TAGS)
  22.         ));
  23.     }
  24. }