@@ -89,6 +89,7 @@ public function configure(DefinitionConfigurator $definition): void
8989 public function loadExtension (array $ config , ContainerConfigurator $ container , ContainerBuilder $ builder ): void
9090 {
9191 $ container ->import ('../config/services.php ' );
92+ $ container ->import ('../config/console.php ' );
9293
9394 foreach ($ config ['platform ' ] ?? [] as $ type => $ platform ) {
9495 $ this ->processPlatformConfig ($ type , $ platform , $ builder );
@@ -115,9 +116,18 @@ public function loadExtension(array $config, ContainerConfigurator $container, C
115116 foreach ($ config ['store ' ] ?? [] as $ type => $ store ) {
116117 $ this ->processStoreConfig ($ type , $ store , $ builder );
117118 }
119+
118120 $ stores = array_keys ($ builder ->findTaggedServiceIds ('ai.store ' ));
119- if (1 === \count ($ stores )) {
120- $ builder ->setAlias (StoreInterface::class, reset ($ stores ));
121+
122+ if ([] !== $ stores ) {
123+ $ references = [];
124+ foreach ($ stores as $ storeName ) {
125+ $ references [$ storeName ] = new Reference ($ storeName );
126+ }
127+
128+ $ builder ->getDefinition ('ai.store_locator ' )->replaceArgument (0 , $ references );
129+ $ builder ->getDefinition ('console.command.ai.setup_store ' )->replaceArgument (0 , $ stores );
130+ $ builder ->getDefinition ('console.command.ai.drop_store ' )->replaceArgument (0 , $ stores );
121131 }
122132
123133 foreach ($ config ['indexer ' ] as $ indexerName => $ indexer ) {
@@ -507,6 +517,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
507517 ->setArguments ($ arguments );
508518
509519 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
520+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
510521 }
511522 }
512523
@@ -538,6 +549,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
538549 ->setArguments ($ arguments );
539550
540551 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
552+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
541553 }
542554 }
543555
@@ -552,6 +564,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
552564 ->addTag ('ai.store ' );
553565
554566 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
567+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
555568 }
556569 }
557570
@@ -578,6 +591,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
578591 ;
579592
580593 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
594+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
581595 }
582596 }
583597
@@ -608,6 +622,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
608622 ->setArguments ($ arguments );
609623
610624 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
625+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
611626 }
612627 }
613628
@@ -632,6 +647,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
632647 ->setArguments ($ arguments );
633648
634649 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
650+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
635651 }
636652 }
637653
@@ -663,6 +679,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
663679 ->setArguments ($ arguments );
664680
665681 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
682+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
666683 }
667684 }
668685
@@ -689,6 +706,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
689706 ->setArguments ($ arguments );
690707
691708 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
709+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
692710 }
693711 }
694712
@@ -726,6 +744,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
726744 ->setArguments ($ arguments );
727745
728746 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
747+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
729748 }
730749 }
731750
@@ -750,6 +769,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
750769 ->setArguments ($ arguments );
751770
752771 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
772+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
753773 }
754774 }
755775
@@ -776,6 +796,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
776796 ->setArguments ($ arguments );
777797
778798 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
799+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
779800 }
780801 }
781802
@@ -816,6 +837,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
816837 ->setArguments ($ arguments );
817838
818839 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
840+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
819841 }
820842 }
821843
@@ -842,6 +864,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
842864 ->setArguments ($ arguments );
843865
844866 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
867+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
845868 }
846869 }
847870 }
0 commit comments