Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add entryExists to EntrypointLookupInterface #167

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Asset/EntrypointLookupInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
9 changes: 2 additions & 7 deletions src/Twig/EntryFilesTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down