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

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