Skip to content

Commit 1efa02a

Browse files
kbondweaverryan
authored andcommitted
[Twig] throw error if twig-bundle is not installed
1 parent 6e87ef5 commit 1efa02a

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)