@@ -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,11 +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+ $ references = [];
123+ foreach ($ stores as $ storeName ) {
124+ $ references [$ storeName ] = new Reference ($ storeName );
121125 }
122126
127+ $ builder ->getDefinition ('ai.store_locator ' )->replaceArgument (0 , $ references );
128+ $ builder ->getDefinition ('console.command.ai.setup_store ' )->replaceArgument (0 , $ stores );
129+ $ builder ->getDefinition ('console.command.ai.drop_store ' )->replaceArgument (0 , $ stores );
130+
123131 foreach ($ config ['indexer ' ] as $ indexerName => $ indexer ) {
124132 $ this ->processIndexerConfig ($ indexerName , $ indexer , $ builder );
125133 }
@@ -507,6 +515,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
507515 ->setArguments ($ arguments );
508516
509517 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
518+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
510519 }
511520 }
512521
@@ -538,6 +547,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
538547 ->setArguments ($ arguments );
539548
540549 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
550+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
541551 }
542552 }
543553
@@ -552,6 +562,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
552562 ->addTag ('ai.store ' );
553563
554564 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
565+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
555566 }
556567 }
557568
@@ -578,6 +589,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
578589 ;
579590
580591 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
592+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
581593 }
582594 }
583595
@@ -608,6 +620,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
608620 ->setArguments ($ arguments );
609621
610622 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
623+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
611624 }
612625 }
613626
@@ -632,6 +645,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
632645 ->setArguments ($ arguments );
633646
634647 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
648+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
635649 }
636650 }
637651
@@ -663,6 +677,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
663677 ->setArguments ($ arguments );
664678
665679 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
680+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
666681 }
667682 }
668683
@@ -689,6 +704,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
689704 ->setArguments ($ arguments );
690705
691706 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
707+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
692708 }
693709 }
694710
@@ -726,6 +742,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
726742 ->setArguments ($ arguments );
727743
728744 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
745+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
729746 }
730747 }
731748
@@ -750,6 +767,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
750767 ->setArguments ($ arguments );
751768
752769 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
770+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
753771 }
754772 }
755773
@@ -776,6 +794,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
776794 ->setArguments ($ arguments );
777795
778796 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
797+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
779798 }
780799 }
781800
@@ -816,6 +835,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
816835 ->setArguments ($ arguments );
817836
818837 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
838+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
819839 }
820840 }
821841
@@ -842,6 +862,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
842862 ->setArguments ($ arguments );
843863
844864 $ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
865+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
845866 }
846867 }
847868 }
0 commit comments