@@ -136,10 +136,8 @@ public function register(): void
136136
137137 $ configure = config ('wallet ' , []);
138138
139- $ this ->contextBinding ($ configure ['cache ' ] ?? []);
140-
141139 $ this ->internal ($ configure ['internal ' ] ?? []);
142- $ this ->services ($ configure ['services ' ] ?? []);
140+ $ this ->services ($ configure ['services ' ] ?? [], $ configure [ ' cache ' ] ?? [] );
143141 $ this ->legacySingleton (); // without configuration
144142
145143 $ this ->repositories ($ configure ['repositories ' ] ?? []);
@@ -176,32 +174,6 @@ private function shouldMigrate(): bool
176174 return WalletConfigure::isRunsMigrations ();
177175 }
178176
179- /** @codeCoverageIgnore */
180- private function contextBinding (array $ bookkeeperStore ): void
181- {
182- $ this ->app ->when (BookkeeperServiceInterface::class)
183- ->needs (StorageServiceInterface::class)
184- ->give (fn () => $ this ->app ->make (
185- StorageServiceInterface::class,
186- [
187- 'cacheRepository ' => $ this ->app ->make (CacheManager::class)
188- ->driver ($ bookkeeperStore ['driver ' ] ?? 'array ' ),
189- ],
190- ))
191- ;
192-
193- $ this ->app ->when (RegulatorServiceInterface::class)
194- ->needs (StorageServiceInterface::class)
195- ->give (fn () => $ this ->app ->make (
196- StorageServiceInterface::class,
197- [
198- 'cacheRepository ' => $ this ->app ->make (CacheManager::class)
199- ->driver ('array ' ),
200- ],
201- ))
202- ;
203- }
204-
205177 private function internal (array $ configure ): void
206178 {
207179 $ this ->app ->bind (StorageServiceInterface::class, $ configure ['storage ' ] ?? StorageService::class);
@@ -216,14 +188,12 @@ private function internal(array $configure): void
216188 $ this ->app ->singleton (UuidFactoryServiceInterface::class, $ configure ['uuid ' ] ?? UuidFactoryService::class);
217189 }
218190
219- private function services (array $ configure ): void
191+ private function services (array $ configure, array $ cache ): void
220192 {
221193 $ this ->app ->singleton (AssistantServiceInterface::class, $ configure ['assistant ' ] ?? AssistantService::class);
222194 $ this ->app ->singleton (AtmServiceInterface::class, $ configure ['atm ' ] ?? AtmService::class);
223195 $ this ->app ->singleton (AtomicServiceInterface::class, $ configure ['atomic ' ] ?? AtomicService::class);
224196 $ this ->app ->singleton (BasketServiceInterface::class, $ configure ['basket ' ] ?? BasketService::class);
225- $ this ->app ->singleton (BookkeeperServiceInterface::class, $ configure ['bookkeeper ' ] ?? BookkeeperService::class);
226- $ this ->app ->singleton (RegulatorServiceInterface::class, $ configure ['regulator ' ] ?? RegulatorService::class);
227197 $ this ->app ->singleton (CastServiceInterface::class, $ configure ['cast ' ] ?? CastService::class);
228198 $ this ->app ->singleton (ConsistencyServiceInterface::class, $ configure ['consistency ' ] ?? ConsistencyService::class);
229199 $ this ->app ->singleton (DiscountServiceInterface::class, $ configure ['discount ' ] ?? DiscountService::class);
@@ -232,6 +202,32 @@ private function services(array $configure): void
232202 $ this ->app ->singleton (PurchaseServiceInterface::class, $ configure ['purchase ' ] ?? PurchaseService::class);
233203 $ this ->app ->singleton (TaxServiceInterface::class, $ configure ['tax ' ] ?? TaxService::class);
234204 $ this ->app ->singleton (WalletServiceInterface::class, $ configure ['wallet ' ] ?? WalletService::class);
205+
206+ $ this ->app ->singleton (BookkeeperServiceInterface::class, fn () => $ this ->app ->make (
207+ $ configure ['bookkeeper ' ] ?? BookkeeperService::class,
208+ [
209+ $ this ->app ->make (
210+ StorageServiceInterface::class,
211+ [
212+ $ this ->app ->make (CacheManager::class)
213+ ->driver ($ cache ['driver ' ] ?? 'array ' ),
214+ ],
215+ ),
216+ ]
217+ ));
218+
219+ $ this ->app ->singleton (RegulatorServiceInterface::class, fn () => $ this ->app ->make (
220+ $ configure ['regulator ' ] ?? RegulatorService::class,
221+ [
222+ $ this ->app ->make (
223+ StorageServiceInterface::class,
224+ [
225+ $ this ->app ->make (CacheManager::class)
226+ ->driver ('array ' ),
227+ ],
228+ ),
229+ ]
230+ ));
235231 }
236232
237233 private function assemblers (array $ configure ): void
0 commit comments