@@ -89,6 +89,7 @@ public function configure(DefinitionConfigurator $definition): void
89
89
public function loadExtension (array $ config , ContainerConfigurator $ container , ContainerBuilder $ builder ): void
90
90
{
91
91
$ container ->import ('../config/services.php ' );
92
+ $ container ->import ('../config/console.php ' );
92
93
93
94
foreach ($ config ['platform ' ] ?? [] as $ type => $ platform ) {
94
95
$ this ->processPlatformConfig ($ type , $ platform , $ builder );
@@ -115,9 +116,18 @@ public function loadExtension(array $config, ContainerConfigurator $container, C
115
116
foreach ($ config ['store ' ] ?? [] as $ type => $ store ) {
116
117
$ this ->processStoreConfig ($ type , $ store , $ builder );
117
118
}
119
+
118
120
$ 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 );
121
131
}
122
132
123
133
foreach ($ config ['indexer ' ] as $ indexerName => $ indexer ) {
@@ -507,6 +517,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
507
517
->setArguments ($ arguments );
508
518
509
519
$ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
520
+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
510
521
}
511
522
}
512
523
@@ -538,6 +549,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
538
549
->setArguments ($ arguments );
539
550
540
551
$ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
552
+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
541
553
}
542
554
}
543
555
@@ -552,6 +564,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
552
564
->addTag ('ai.store ' );
553
565
554
566
$ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
567
+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
555
568
}
556
569
}
557
570
@@ -578,6 +591,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
578
591
;
579
592
580
593
$ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
594
+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
581
595
}
582
596
}
583
597
@@ -608,6 +622,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
608
622
->setArguments ($ arguments );
609
623
610
624
$ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
625
+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
611
626
}
612
627
}
613
628
@@ -632,6 +647,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
632
647
->setArguments ($ arguments );
633
648
634
649
$ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
650
+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
635
651
}
636
652
}
637
653
@@ -663,6 +679,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
663
679
->setArguments ($ arguments );
664
680
665
681
$ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
682
+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
666
683
}
667
684
}
668
685
@@ -689,6 +706,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
689
706
->setArguments ($ arguments );
690
707
691
708
$ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
709
+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
692
710
}
693
711
}
694
712
@@ -726,6 +744,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
726
744
->setArguments ($ arguments );
727
745
728
746
$ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
747
+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
729
748
}
730
749
}
731
750
@@ -750,6 +769,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
750
769
->setArguments ($ arguments );
751
770
752
771
$ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
772
+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
753
773
}
754
774
}
755
775
@@ -776,6 +796,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
776
796
->setArguments ($ arguments );
777
797
778
798
$ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
799
+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
779
800
}
780
801
}
781
802
@@ -816,6 +837,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
816
837
->setArguments ($ arguments );
817
838
818
839
$ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
840
+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
819
841
}
820
842
}
821
843
@@ -842,6 +864,7 @@ private function processStoreConfig(string $type, array $stores, ContainerBuilde
842
864
->setArguments ($ arguments );
843
865
844
866
$ container ->setDefinition ('ai.store. ' .$ type .'. ' .$ name , $ definition );
867
+ $ container ->registerAliasForArgument ('ai.store. ' .$ name , StoreInterface::class, (new Target ($ name .'Store ' ))->getParsedName ());
845
868
}
846
869
}
847
870
}
0 commit comments