src/Backend/Modules/Mailmotor/EventListener/SettingsSavedListener.php line 23

Open in your IDE?
  1. <?php
  2. namespace Backend\Modules\Mailmotor\EventListener;
  3. use Backend\Modules\Mailmotor\Domain\Settings\Event\SettingsSavedEvent;
  4. use Symfony\Component\Filesystem\Filesystem;
  5. /**
  6.  * Settings saved listener
  7.  */
  8. final class SettingsSavedListener
  9. {
  10.     /**
  11.      * @var string
  12.      */
  13.     private $cacheDirectory;
  14.     public function __construct(string $cacheDirectory)
  15.     {
  16.         $this->cacheDirectory $cacheDirectory;
  17.     }
  18.     public function onSettingsSavedEvent(): void
  19.     {
  20.         /**
  21.          * We must remove our container cache after this request.
  22.          * Because this is not only saved in the module settings,
  23.          * but the compiler pass pushes this in the container.
  24.          * The settings cache is cleared, but the container should be cleared too,
  25.          * to make it rebuild with the new chosen engine
  26.          */
  27.         $fs = new Filesystem();
  28.         $fs->remove($this->cacheDirectory);
  29.     }
  30. }