Skip to content

Commit

Permalink
Ignore unresolvable non-anonymous component template paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
rarila committed Dec 3, 2023
1 parent 9ca3944 commit 22c4cd8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/TwigComponent/src/Command/TwigComponentDebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Symfony\UX\TwigComponent\ComponentMetadata;
use Symfony\UX\TwigComponent\Twig\PropsNode;
use Twig\Environment;
use Twig\Error\LoaderError;

#[AsCommand(name: 'debug:twig-component', description: 'Display components and them usages for an application')]
class TwigComponentDebugCommand extends Command
Expand Down Expand Up @@ -137,8 +138,13 @@ private function findComponents(): array
$metadata = $this->componentFactory->metadataFor($name);
$components[$name] ??= $metadata;
$template = $metadata->getTemplate();
$resolvedPath = $loader->getSourceContext($template)->getPath();
$usedResolvedTemplatePaths[$resolvedPath] = true;

try {
$resolvedPath = $loader->getSourceContext($template)->getPath();
$usedResolvedTemplatePaths[$resolvedPath] = true;
} catch (LoaderError) {
// Ignore unresolvable paths.
}
}

foreach ($this->findAnonymousComponents() as $name) {
Expand Down

0 comments on commit 22c4cd8

Please sign in to comment.