Skip to content

Commit ee3f3dc

Browse files
authored
Merge pull request #432 from bavix/8.x-fix
8.0.1 fix service provider (custom cache)
2 parents cbafc10 + 3c422f0 commit ee3f3dc

File tree

3 files changed

+39
-38
lines changed

3 files changed

+39
-38
lines changed

.github/workflows/phpunits.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
--health-cmd "redis-cli ping"
3030
--health-interval 10s
3131
--health-timeout 5s
32-
--health-retries 5
32+
--health-retries 10
3333
ports:
3434
- 6379:6379
3535

@@ -39,7 +39,7 @@ jobs:
3939
--health-cmd "timeout 5 bash -c 'cat < /dev/null > /dev/udp/127.0.0.1/11211'"
4040
--health-interval 10s
4141
--health-timeout 5s
42-
--health-retries 5
42+
--health-retries 10
4343
ports:
4444
- 11211:11211
4545

@@ -53,7 +53,7 @@ jobs:
5353
--health-cmd pg_isready
5454
--health-interval 10s
5555
--health-timeout 5s
56-
--health-retries 3
56+
--health-retries 10
5757
ports:
5858
- 5432:5432
5959

@@ -67,7 +67,7 @@ jobs:
6767
--health-cmd="mysqladmin ping"
6868
--health-interval 10s
6969
--health-timeout 5s
70-
--health-retries 3
70+
--health-retries 10
7171
ports:
7272
- 3306:3306
7373

@@ -80,7 +80,7 @@ jobs:
8080
--health-cmd="mysqladmin ping"
8181
--health-interval 10s
8282
--health-timeout 5s
83-
--health-retries 3
83+
--health-retries 10
8484
ports:
8585
- 3307:3306
8686

changelog.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [8.0.1] - 2022-02-12
10+
### Fixed
11+
- Fixed bug preventing redis from being used #429 @mattvb91
12+
913
## [8.0.0] - 2022-02-08
1014
### Added
1115
- Add support laravel ^9.0
@@ -768,7 +772,8 @@ The operation is now executed in the transaction and updates the new `refund` fi
768772
- Exceptions: AmountInvalid, BalanceIsEmpty.
769773
- Models: Transfer, Transaction.
770774

771-
[Unreleased]: https://github.com/bavix/laravel-wallet/compare/8.0.0...develop
775+
[Unreleased]: https://github.com/bavix/laravel-wallet/compare/8.0.1...develop
776+
[8.0.1]: https://github.com/bavix/laravel-wallet/compare/8.0.0...8.0.1
772777
[8.0.0]: https://github.com/bavix/laravel-wallet/compare/7.3.0...8.0.0
773778
[7.3.0]: https://github.com/bavix/laravel-wallet/compare/7.2.0...7.3.0
774779
[7.2.0]: https://github.com/bavix/laravel-wallet/compare/7.1.0...7.2.0

src/WalletServiceProvider.php

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)