Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7785df0

Browse files
committed
suggest to install the Twig bridge when the required component is installed
1 parent f86f383 commit 7785df0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Symfony/Bridge/Twig/UndefinedCallableHandler.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bridge\Twig;
1313

14+
use Composer\InstalledVersions;
1415
use Symfony\Bundle\FullStack;
1516
use Twig\Error\SyntaxError;
1617

@@ -93,6 +94,12 @@ private static function onUndefined(string $name, string $type, string $componen
9394
throw new SyntaxError(sprintf('Did you forget to %s? Unknown %s "%s".', self::FULL_STACK_ENABLE[$component], $type, $name));
9495
}
9596

96-
throw new SyntaxError(sprintf('Did you forget to run "composer require symfony/%s"? Unknown %s "%s".', $component, $type, $name));
97+
$missingPackage = 'symfony/'.$component;
98+
99+
if (class_exists(InstalledVersions::class) && InstalledVersions::isInstalled($missingPackage)) {
100+
$missingPackage = 'symfony/twig-bridge';
101+
}
102+
103+
throw new SyntaxError(sprintf('Did you forget to run "composer require %s"? Unknown %s "%s".', $missingPackage, $type, $name));
97104
}
98105
}

0 commit comments

Comments
 (0)