Skip to content

Commit

Permalink
bug #47171 [TwigBridge] suggest to install the Twig bundle when the r…
Browse files Browse the repository at this point in the history
…equired component is already installed (xabbuh)

This PR was merged into the 4.4 branch.

Discussion
----------

[TwigBridge] suggest to install the Twig bundle when the required component is already installed

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #43560
| License       | MIT
| Doc PR        |

Commits
-------

c203ef2 suggest to install the Twig bundle when the required component is already installed
  • Loading branch information
nicolas-grekas committed Aug 3, 2022
2 parents f86f383 + c203ef2 commit 0420d3c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Symfony/Bridge/Twig/UndefinedCallableHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bridge\Twig;

use Composer\InstalledVersions;
use Symfony\Bundle\FullStack;
use Twig\Error\SyntaxError;

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

throw new SyntaxError(sprintf('Did you forget to run "composer require symfony/%s"? Unknown %s "%s".', $component, $type, $name));
$missingPackage = 'symfony/'.$component;

if (class_exists(InstalledVersions::class) && InstalledVersions::isInstalled($missingPackage)) {
$missingPackage = 'symfony/twig-bundle';
}

throw new SyntaxError(sprintf('Did you forget to run "composer require %s"? Unknown %s "%s".', $missingPackage, $type, $name));
}
}

0 comments on commit 0420d3c

Please sign in to comment.