25
25
use TheCodingMachine \TDBM \Schema \LockFileSchemaManager ;
26
26
use TheCodingMachine \TDBM \TDBMService ;
27
27
use TheCodingMachine \TDBM \Utils \Annotation \AnnotationParser ;
28
+ use TheCodingMachine \TDBM \Utils \CodeGeneratorListenerInterface ;
28
29
use TheCodingMachine \TDBM \Utils \DefaultNamingStrategy ;
30
+ use TheCodingMachine \TDBM \Utils \GeneratorListenerInterface ;
29
31
use TheCodingMachine \TDBM \Utils \NamingStrategyInterface ;
30
32
use TheCodingMachine \TDBM \SchemaLockFileDumper ;
31
33
use TheCodingMachine \TDBM \Utils \RootProjectLocator ;
39
41
40
42
class TdbmExtension extends Extension
41
43
{
44
+ public const TAG_GENERATOR_LISTENER = 'tdbm.generatorListener ' ;
45
+ public const TAG_CODE_GENERATOR_LISTENER = 'tdbm.codeGeneratorListener ' ;
46
+ public const TAG_TDBM_CONFIGURATION = 'tdbm.configuration ' ;
47
+
42
48
private const DEFAULT_CONFIGURATION_ID = TDBMConfiguration::class;
43
49
private const DEFAULT_NAMING_STRATEGY_ID = DefaultNamingStrategy::class;
44
50
@@ -51,6 +57,9 @@ class TdbmExtension extends Extension
51
57
*/
52
58
public function load (array $ configs , ContainerBuilder $ container ): void
53
59
{
60
+ $ container ->registerForAutoconfiguration (GeneratorListenerInterface::class)->addTag (self ::TAG_GENERATOR_LISTENER );
61
+ $ container ->registerForAutoconfiguration (CodeGeneratorListenerInterface::class)->addTag (self ::TAG_CODE_GENERATOR_LISTENER );
62
+
54
63
$ configuration = new Configuration ();
55
64
$ processedConfig = $ this ->processConfiguration ($ configuration , $ configs );
56
65
@@ -138,8 +147,8 @@ private function getConfigurationDefinition(ConnectionConfiguration $config, str
138
147
$ configuration ->setArgument (1 , $ config ->getDaoNamespace ());
139
148
$ configuration ->setArgument ('$connection ' , new Reference ($ config ->getConnection ()));
140
149
$ configuration ->setArgument ('$namingStrategy ' , new Reference ($ namingStrategyServiceId ));
141
- $ configuration ->setArgument ('$codeGeneratorListeners ' , [new Reference (SymfonyCodeGeneratorListener::class)]);
142
150
$ configuration ->setArgument ('$cache ' , new Reference ('tdbm.cache ' ));
151
+ $ configuration ->addTag (self ::TAG_TDBM_CONFIGURATION );
143
152
144
153
// Let's name the tdbm lock file after the name of the DBAL connection.
145
154
0 commit comments