Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 953288c

Browse files
[FrameworkBundle] Auto-exclude DI extensions, kernel, test cases and messenger messages
1 parent c3c37f2 commit 953288c

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ CHANGELOG
1414
* Add support for signal plain name in the `messenger.stop_worker_on_signals` configuration
1515
* Deprecate the `framework.validation.cache` option
1616
* Add `--method` option to the `debug:router` command
17+
* Auto-exclude DI extensions, kernel, test cases and messenger messages
1718

1819
7.2
1920
---

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
1313

1414
use Composer\InstalledVersions;
15+
use Doctrine\ORM\Mapping\Entity;
1516
use Http\Client\HttpAsyncClient;
1617
use Http\Client\HttpClient;
1718
use phpDocumentor\Reflection\DocBlockFactoryInterface;
1819
use phpDocumentor\Reflection\Types\ContextFactory;
1920
use PhpParser\Parser;
2021
use PHPStan\PhpDocParser\Parser\PhpDocParser;
22+
use PHPUnit\Framework\TestCase;
2123
use Psr\Cache\CacheItemPoolInterface;
2224
use Psr\Clock\ClockInterface as PsrClockInterface;
2325
use Psr\Container\ContainerInterface as PsrContainerInterface;
@@ -57,6 +59,7 @@
5759
use Symfony\Component\DependencyInjection\Alias;
5860
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
5961
use Symfony\Component\DependencyInjection\ChildDefinition;
62+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6063
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
6164
use Symfony\Component\DependencyInjection\ContainerBuilder;
6265
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -99,6 +102,7 @@
99102
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
100103
use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
101104
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
105+
use Symfony\Component\HttpKernel\KernelInterface;
102106
use Symfony\Component\HttpKernel\Log\DebugLoggerConfigurator;
103107
use Symfony\Component\JsonStreamer\Attribute\JsonStreamable;
104108
use Symfony\Component\JsonStreamer\JsonStreamWriter;
@@ -117,6 +121,7 @@
117121
use Symfony\Component\Mailer\EventListener\SmimeSignedMessageListener;
118122
use Symfony\Component\Mailer\Mailer;
119123
use Symfony\Component\Mercure\HubRegistry;
124+
use Symfony\Component\Messenger\Attribute\AsMessage;
120125
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
121126
use Symfony\Component\Messenger\Bridge as MessengerBridge;
122127
use Symfony\Component\Messenger\Handler\BatchHandlerInterface;
@@ -757,12 +762,25 @@ static function (ChildDefinition $definition, AsPeriodicTask|AsCronTask $attribu
757762
}
758763
);
759764
}
760-
$container->registerAttributeForAutoconfiguration(JsonStreamable::class, static function (ChildDefinition $definition, JsonStreamable $attribute): void {
761-
$definition->addTag('json_streamer.streamable', [
765+
766+
$container->registerForAutoconfiguration(CompilerPassInterface::class)
767+
->addExcludeTag('container.excluded.compiler_pass');
768+
$container->registerForAutoconfiguration(KernelInterface::class)
769+
->addExcludeTag('container.excluded.kernel');
770+
$container->registerForAutoconfiguration(TestCase::class)
771+
->addExcludeTag('container.excluded.test_case');
772+
$container->registerAttributeForAutoconfiguration(AsMessage::class, static function (ChildDefinition $definition) {
773+
$definition->addExcludeTag('container.excluded.messenger.message');
774+
});
775+
$container->registerAttributeForAutoconfiguration(Entity::class, static function (ChildDefinition $definition) {
776+
$definition->addExcludeTag('container.excluded.doctrine.entity');
777+
});
778+
779+
$container->registerAttributeForAutoconfiguration(JsonStreamable::class, static function (ChildDefinition $definition, JsonStreamable $attribute) {
780+
$definition->addExcludeTag('json_streamer.streamable', [
762781
'object' => $attribute->asObject,
763782
'list' => $attribute->asList,
764783
]);
765-
$definition->addTag('container.excluded');
766784
});
767785

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

0 commit comments

Comments
 (0)