Skip to content

Commit 8010bef

Browse files
committed
minor #313 [Twig] throw error if twig-bundle is not installed (kbond)
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Twig] throw error if twig-bundle is not installed | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Tickets | n/a | License | MIT Ran into an issue with `ContainerBuilder::willBeAvailable()` and `ux-live-component`'s test suite when requiring `symfony/twig-bundle` directly. Not perfect but throwing an exception on container build if `twig-bundle` is not available seemed like the easiest solution. Commits ------- 1efa02a [Twig] throw error if twig-bundle is not installed
2 parents 6e87ef5 + 1efa02a commit 8010bef

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

.github/workflows/test.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ jobs:
108108
- uses: shivammathur/setup-php@v2
109109
with:
110110
php-version: '8.0'
111-
- run: php .github/build-packages.php
112111

113112
- name: TwigComponent Dependencies
114113
uses: ramsey/composer-install@v2

src/TwigComponent/src/DependencyInjection/TwigComponentExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
1717
use Symfony\Component\DependencyInjection\ChildDefinition;
1818
use Symfony\Component\DependencyInjection\ContainerBuilder;
19+
use Symfony\Component\DependencyInjection\Exception\LogicException;
1920
use Symfony\Component\DependencyInjection\Extension\Extension;
2021
use Symfony\Component\DependencyInjection\Reference;
2122
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
@@ -36,6 +37,10 @@ final class TwigComponentExtension extends Extension
3637
{
3738
public function load(array $configs, ContainerBuilder $container): void
3839
{
40+
if (!isset($container->getParameter('kernel.bundles')['TwigBundle'])) {
41+
throw new LogicException('The TwigBundle is not registered in your application. Try running "composer require symfony/twig-bundle".');
42+
}
43+
3944
$container->registerAttributeForAutoconfiguration(
4045
AsTwigComponent::class,
4146
static function (ChildDefinition $definition, AsTwigComponent $attribute) {

0 commit comments

Comments
 (0)