Skip to content

Commit 33a91b7

Browse files
[FrameworkBundle] Exclude validator constrains, attributes, enums from the container
1 parent 25130be commit 33a91b7

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@
204204
use Symfony\Component\TypeInfo\TypeResolver\TypeResolverInterface;
205205
use Symfony\Component\Uid\Factory\UuidFactory;
206206
use Symfony\Component\Uid\UuidV4;
207+
use Symfony\Component\Validator\Constraint;
207208
use Symfony\Component\Validator\Constraints\ExpressionLanguageProvider;
208209
use Symfony\Component\Validator\ConstraintValidatorInterface;
209210
use Symfony\Component\Validator\GroupProviderInterface;
@@ -786,29 +787,34 @@ static function (ChildDefinition $definition, AsPeriodicTask|AsCronTask $attribu
786787
}
787788

788789
$container->registerForAutoconfiguration(CompilerPassInterface::class)
789-
->addTag('container.excluded.compiler_pass')->addTag('container.excluded')->setAbstract(true);
790+
->addTag('container.excluded', ['source' => 'because it\'s a compiler pass'])->setAbstract(true);
791+
$container->registerForAutoconfiguration(Constraint::class)
792+
->addTag('container.excluded', ['source' => 'because it\'s a validation constraint'])->setAbstract(true);
790793
$container->registerForAutoconfiguration(TestCase::class)
791-
->addTag('container.excluded.test_case')->addTag('container.excluded')->setAbstract(true);
794+
->addTag('container.excluded', ['source' => 'because it\'s a test case'])->setAbstract(true);
795+
$container->registerForAutoconfiguration(\UnitEnum::class)
796+
->addTag('container.excluded', ['source' => 'because it\'s an enum'])->setAbstract(true);
792797
$container->registerAttributeForAutoconfiguration(AsMessage::class, static function (ChildDefinition $definition) {
793-
$definition->addTag('container.excluded.messenger.message')->addTag('container.excluded')->setAbstract(true);
798+
$definition->addTag('container.excluded', ['source' => 'because it\'s a messenger message'])->setAbstract(true);
799+
});
800+
$container->registerAttributeForAutoconfiguration(\Attribute::class, static function (ChildDefinition $definition) {
801+
$definition->addTag('container.excluded', ['source' => 'because it\'s an attribute'])->setAbstract(true);
794802
});
795803
$container->registerAttributeForAutoconfiguration(Entity::class, static function (ChildDefinition $definition) {
796-
$definition->addTag('container.excluded.doctrine.entity')->addTag('container.excluded')->setAbstract(true);
804+
$definition->addTag('container.excluded', ['source' => 'because it\'s a doctrine entity'])->setAbstract(true);
797805
});
798806
$container->registerAttributeForAutoconfiguration(Embeddable::class, static function (ChildDefinition $definition) {
799-
$definition->addTag('container.excluded.doctrine.embeddable')->addTag('container.excluded')->setAbstract(true);
807+
$definition->addTag('container.excluded', ['source' => 'because it\'s a doctrine embeddable'])->setAbstract(true);
800808
});
801809
$container->registerAttributeForAutoconfiguration(MappedSuperclass::class, static function (ChildDefinition $definition) {
802-
$definition->addTag('container.excluded.doctrine.mapped_superclass')->addTag('container.excluded')->setAbstract(true);
810+
$definition->addTag('container.excluded', ['source' => 'because it\'s a doctrine mapped superclass'])->setAbstract(true);
803811
});
804812

805813
$container->registerAttributeForAutoconfiguration(JsonStreamable::class, static function (ChildDefinition $definition, JsonStreamable $attribute) {
806814
$definition->addTag('json_streamer.streamable', [
807815
'object' => $attribute->asObject,
808816
'list' => $attribute->asList,
809-
]);
810-
$definition->addTag('container.excluded');
811-
$definition->setAbstract(true);
817+
])->addTag('container.excluded', ['source' => 'because it\'s a streamable JSON'])->setAbstract(true);
812818
});
813819

814820
if (!$container->getParameter('kernel.debug')) {

0 commit comments

Comments
 (0)