diff --git a/src/Plugin/PluginInterface.php b/src/Plugin/PluginInterface.php index f90dd3fe..46863a4b 100644 --- a/src/Plugin/PluginInterface.php +++ b/src/Plugin/PluginInterface.php @@ -2,9 +2,6 @@ namespace Tienvx\Bundle\MbtBundle\Plugin; -use Symfony\Component\DependencyInjection\Attribute\Autoconfigure; - -#[Autoconfigure(tags: [PluginInterface::TAG], lazy: true)] interface PluginInterface { public const TAG = 'mbt_bundle.plugin'; diff --git a/src/TienvxMbtBundle.php b/src/TienvxMbtBundle.php index 14d2ceae..99c2b638 100644 --- a/src/TienvxMbtBundle.php +++ b/src/TienvxMbtBundle.php @@ -8,6 +8,7 @@ use Symfony\Component\HttpKernel\Bundle\AbstractBundle; use Tienvx\Bundle\MbtBundle\Command\CommandManager; use Tienvx\Bundle\MbtBundle\DependencyInjection\Compiler\PluginPass; +use Tienvx\Bundle\MbtBundle\Plugin\PluginInterface; use Tienvx\Bundle\MbtBundle\Service\SelenoidHelper; class TienvxMbtBundle extends AbstractBundle @@ -37,5 +38,8 @@ public function loadExtension(array $config, ContainerConfigurator $container, C ->get(CommandManager::class) ->call('setUploadDir', [$config[static::UPLOAD_DIR]]) ; + $builder->registerForAutoconfiguration(PluginInterface::class) + ->setLazy(true) + ->addTag(PluginInterface::TAG); } } diff --git a/tests/TienvxMbtBundleTest.php b/tests/TienvxMbtBundleTest.php index 52049106..30b5dfec 100644 --- a/tests/TienvxMbtBundleTest.php +++ b/tests/TienvxMbtBundleTest.php @@ -11,6 +11,7 @@ use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Tienvx\Bundle\MbtBundle\Command\CommandManager; use Tienvx\Bundle\MbtBundle\DependencyInjection\Compiler\PluginPass; +use Tienvx\Bundle\MbtBundle\Plugin\PluginInterface; use Tienvx\Bundle\MbtBundle\Service\SelenoidHelper; use Tienvx\Bundle\MbtBundle\TienvxMbtBundle; @@ -73,5 +74,8 @@ public function testLoadExtension(): void $this->assertSame([ ['setUploadDir', [static::CONFIG[TienvxMbtBundle::UPLOAD_DIR]]], ], $this->builder->findDefinition(CommandManager::class)->getMethodCalls()); + $autoConfigured = $this->builder->getAutoconfiguredInstanceof()[PluginInterface::class]; + $this->assertTrue($autoConfigured->hasTag(PluginInterface::TAG)); + $this->assertTrue($autoConfigured->isLazy()); } }