vendor/symfony/webpack-encore-bundle/src/EventListener/ResetAssetsEventListener.php line 39

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of the Symfony WebpackEncoreBundle package.
  5.  *
  6.  * (c) Fabien Potencier <fabien@symfony.com>
  7.  *
  8.  * For the full copyright and license information, please view the LICENSE
  9.  * file that was distributed with this source code.
  10.  */
  11. namespace Symfony\WebpackEncoreBundle\EventListener;
  12. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  13. use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
  14. use Symfony\Component\HttpKernel\KernelEvents;
  15. use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupCollection;
  16. class ResetAssetsEventListener implements EventSubscriberInterface
  17. {
  18.     private $entrypointLookupCollection;
  19.     private $buildNames;
  20.     public function __construct(EntrypointLookupCollection $entrypointLookupCollection, array $buildNames)
  21.     {
  22.         $this->entrypointLookupCollection $entrypointLookupCollection;
  23.         $this->buildNames $buildNames;
  24.     }
  25.     public static function getSubscribedEvents(): array
  26.     {
  27.         return [
  28.             KernelEvents::FINISH_REQUEST => 'resetAssets',
  29.         ];
  30.     }
  31.     public function resetAssets(FinishRequestEvent $event): void
  32.     {
  33.         if (!$event->isMainRequest()) {
  34.             return;
  35.         }
  36.         foreach ($this->buildNames as $name) {
  37.             $this->entrypointLookupCollection->getEntrypointLookup($name)->reset();
  38.         }
  39.     }
  40. }