Skip to content

Commit

Permalink
Exclude classes with #[Document] attribute from container
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Jan 6, 2025
1 parent 97a7737 commit d954321
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/DependencyInjection/DoctrineMongoDBExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Doctrine\Common\EventSubscriber;
use Doctrine\ODM\MongoDB\Configuration as ODMConfiguration;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Mapping\Annotations\Document;
use Doctrine\ODM\MongoDB\Mapping\Driver\AttributeDriver;
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
use InvalidArgumentException;
Expand Down Expand Up @@ -143,6 +144,10 @@ public function load(array $configs, ContainerBuilder $container): void
]);
});

$container->registerAttributeForAutoconfiguration(Document::class, static function (ChildDefinition $definition): void {
$definition->addTag('container.excluded');

Check warning on line 148 in src/DependencyInjection/DoctrineMongoDBExtension.php

View check run for this annotation

Codecov / codecov/patch

src/DependencyInjection/DoctrineMongoDBExtension.php#L148

Added line #L148 was not covered by tests
});

$this->loadMessengerServices($container, $loader);

$this->loadEntityValueResolverServices($container, $loader, $config);
Expand Down

0 comments on commit d954321

Please sign in to comment.