src/EventSubscriber/FixtureEventSubscriber.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use App\Event\FixtureLoadedEvent;
  4. use App\Factory\AssetFactory;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Symfony\Component\Filesystem\Filesystem;
  7. class FixtureEventSubscriber implements EventSubscriberInterface
  8. {
  9.     protected Filesystem $filesystem;
  10.     protected string $projectDir;
  11.     public function __construct(
  12.         Filesystem $filesystem,
  13.         string $projectDir
  14.     ) {
  15.         $this->filesystem $filesystem;
  16.         $this->projectDir $projectDir;
  17.     }
  18.     public static function getSubscribedEvents()
  19.     {
  20.         return [
  21.             FixtureLoadedEvent::class => 'fixturesLoaded',
  22.         ];
  23.     }
  24.     public function fixturesLoaded()
  25.     {
  26.         $fixtureDir sprintf('%s/%s'$this->projectDirAssetFactory::TEMP_FOLDER);
  27.         if (!$this->filesystem->exists($fixtureDir)) {
  28.             return;
  29.         }
  30.         $this->filesystem->remove($fixtureDir);
  31.     }
  32. }