Skip to content

Commit 04bbe69

Browse files
committed
don't register the Twig validator with symfony/twig-bridge < 7.3
1 parent 195f1f1 commit 04bbe69

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\TwigBundle\DependencyInjection;
1313

14+
use Symfony\Bridge\Twig\Validator\Constraints\TwigValidator;
1415
use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\AttributeExtensionPass;
1516
use Symfony\Component\AssetMapper\AssetMapper;
1617
use Symfony\Component\Config\FileLocator;
@@ -25,7 +26,6 @@
2526
use Symfony\Component\Mailer\Mailer;
2627
use Symfony\Component\Translation\LocaleSwitcher;
2728
use Symfony\Component\Translation\Translator;
28-
use Symfony\Component\Validator\Constraint;
2929
use Symfony\Contracts\Service\ResetInterface;
3030
use Twig\Attribute\AsTwigFilter;
3131
use Twig\Attribute\AsTwigFunction;
@@ -70,7 +70,7 @@ public function load(array $configs, ContainerBuilder $container): void
7070
$container->removeDefinition('twig.translation.extractor');
7171
}
7272

73-
if ($container::willBeAvailable('symfony/validator', Constraint::class, ['symfony/twig-bundle'])) {
73+
if ($container::willBeAvailable('symfony/twig-bridge', TwigValidator::class, ['symfony/twig-bundle'])) {
7474
$loader->load('validator.php');
7575
}
7676

src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection;
1313

1414
use Symfony\Bridge\PhpUnit\ExpectUserDeprecationMessageTrait;
15+
use Symfony\Bridge\Twig\Validator\Constraints\TwigValidator;
1516
use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\RuntimeLoaderPass;
1617
use Symfony\Bundle\TwigBundle\DependencyInjection\TwigExtension;
1718
use Symfony\Bundle\TwigBundle\Tests\DependencyInjection\AcmeBundle\AcmeBundle;
@@ -54,6 +55,12 @@ public function testLoadEmptyConfiguration()
5455
if (class_exists(Mailer::class)) {
5556
$this->assertCount(2, $container->getDefinition('twig.mime_body_renderer')->getArguments());
5657
}
58+
59+
if (class_exists(TwigValidator::class)) {
60+
$this->assertTrue($container->hasDefinition('twig.validator'));
61+
} else {
62+
$this->assertFalse($container->hasDefinition('twig.validator'));
63+
}
5764
}
5865

5966
/**

src/Symfony/Bundle/TwigBundle/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"symfony/translation": "^6.4|^7.0",
3636
"symfony/yaml": "^6.4|^7.0",
3737
"symfony/framework-bundle": "^6.4|^7.0",
38+
"symfony/validator": "^6.4|^7.0",
3839
"symfony/web-link": "^6.4|^7.0"
3940
},
4041
"conflict": {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy