diff --git a/src/Asset/EntrypointLookupInterface.php b/src/Asset/EntrypointLookupInterface.php index 9445b84d..f318a967 100644 --- a/src/Asset/EntrypointLookupInterface.php +++ b/src/Asset/EntrypointLookupInterface.php @@ -28,4 +28,6 @@ public function getCssFiles(string $entryName): array; * Resets the state of this service. */ public function reset(); + + public function entryExists(string $entryName): bool; } diff --git a/src/Twig/EntryFilesTwigExtension.php b/src/Twig/EntryFilesTwigExtension.php index 253704c0..7338b3b8 100644 --- a/src/Twig/EntryFilesTwigExtension.php +++ b/src/Twig/EntryFilesTwigExtension.php @@ -10,7 +10,6 @@ namespace Symfony\WebpackEncoreBundle\Twig; use Psr\Container\ContainerInterface; -use Symfony\WebpackEncoreBundle\Asset\EntrypointLookup; use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupInterface; use Symfony\WebpackEncoreBundle\Asset\TagRenderer; use Twig\Extension\AbstractExtension; @@ -62,12 +61,8 @@ public function renderWebpackLinkTags(string $entryName, string $packageName = n public function entryExists(string $entryName, string $entrypointName = '_default'): bool { - $entrypointLookup = $this->getEntrypointLookup($entrypointName); - if (!$entrypointLookup instanceof EntrypointLookup) { - throw new \LogicException(sprintf('Cannot use entryExists() unless the entrypoint lookup is an instance of "%s"', EntrypointLookup::class)); - } - - return $entrypointLookup->entryExists($entryName); + return $this->getEntrypointLookup($entrypointName) + ->entryExists($entryName); } private function getEntrypointLookup(string $entrypointName): EntrypointLookupInterface