From d5e42311504134ec7a63404b4bee6e669b688e54 Mon Sep 17 00:00:00 2001 From: Louis Charette Date: Sun, 20 Mar 2022 19:38:27 -0400 Subject: [PATCH 1/2] Add entryExists to EntrypointLookupInterface --- src/Asset/EntrypointLookupInterface.php | 2 ++ src/Twig/EntryFilesTwigExtension.php | 8 ++------ 2 files changed, 4 insertions(+), 6 deletions(-) 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..16e6fa5f 100644 --- a/src/Twig/EntryFilesTwigExtension.php +++ b/src/Twig/EntryFilesTwigExtension.php @@ -62,12 +62,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 From 550246323e622bcc5b65b2f2138cf682d33b143d Mon Sep 17 00:00:00 2001 From: Louis Charette Date: Sun, 20 Mar 2022 19:50:46 -0400 Subject: [PATCH 2/2] Fix style --- src/Twig/EntryFilesTwigExtension.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Twig/EntryFilesTwigExtension.php b/src/Twig/EntryFilesTwigExtension.php index 16e6fa5f..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;