Skip to content

Commit 66a1308

Browse files
committed
fixed for laravel octane
1 parent 2260214 commit 66a1308

File tree

6 files changed

+25
-32
lines changed

6 files changed

+25
-32
lines changed

deptrac.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ parameters:
5050
- type: className
5151
regex: ^Bavix\\.*\\Internal\\Exceptions\\.*
5252

53+
- name: InternalListener
54+
collectors:
55+
- type: className
56+
regex: ^Bavix\\.*\\Internal\\Listeners\\.*
57+
5358
- name: Event
5459
collectors:
5560
- type: className
@@ -250,6 +255,9 @@ parameters:
250255
- UIException
251256
- Model
252257

258+
InternalListener:
259+
- ServiceInterface
260+
253261
ServiceInterface:
254262
- InternalException
255263
- EventInterface

src/Internal/Listeners/TransactionBeginningListener.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,10 @@
99

1010
final class TransactionBeginningListener
1111
{
12-
public function __construct(
13-
private ConnectionServiceInterface $connectionService,
14-
private RegulatorServiceInterface $regulatorService
15-
) {
16-
}
17-
1812
public function __invoke(): void
1913
{
20-
if ($this->connectionService->get()->transactionLevel() === 1) {
21-
$this->regulatorService->purge();
14+
if (app(ConnectionServiceInterface::class)->get()->transactionLevel() === 1) {
15+
app(RegulatorServiceInterface::class)->purge();
2216
}
2317
}
2418
}

src/Internal/Listeners/TransactionCommittedListener.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,10 @@
99

1010
final class TransactionCommittedListener
1111
{
12-
public function __construct(
13-
private ConnectionServiceInterface $connectionService,
14-
private RegulatorServiceInterface $regulatorService
15-
) {
16-
}
17-
1812
public function __invoke(): void
1913
{
20-
if ($this->connectionService->get()->transactionLevel() === 0) {
21-
$this->regulatorService->committed();
14+
if (app(ConnectionServiceInterface::class)->get()->transactionLevel() === 0) {
15+
app(RegulatorServiceInterface::class)->committed();
2216
}
2317
}
2418
}

src/Internal/Listeners/TransactionCommittingListener.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,14 @@
99

1010
final class TransactionCommittingListener
1111
{
12-
public function __construct(
13-
private ConnectionServiceInterface $connectionService,
14-
private RegulatorServiceInterface $regulatorService
15-
) {
16-
}
17-
1812
public function __invoke(): void
1913
{
2014
/**
2115
* In fact, this if is not needed here.
2216
* But in order to protect the code from changes in the framework, I added a check here.
2317
*/
24-
if ($this->connectionService->get()->transactionLevel() === 1) {
25-
$this->regulatorService->committing();
18+
if (app(ConnectionServiceInterface::class)->get()->transactionLevel() === 1) {
19+
app(RegulatorServiceInterface::class)->committing();
2620
}
2721
}
2822
}

src/Internal/Listeners/TransactionRolledBackListener.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,10 @@
99

1010
final class TransactionRolledBackListener
1111
{
12-
public function __construct(
13-
private ConnectionServiceInterface $connectionService,
14-
private RegulatorServiceInterface $regulatorService
15-
) {
16-
}
17-
1812
public function __invoke(): void
1913
{
20-
if ($this->connectionService->get()->transactionLevel() === 0) {
21-
$this->regulatorService->purge();
14+
if (app(ConnectionServiceInterface::class)->get()->transactionLevel() === 0) {
15+
app(RegulatorServiceInterface::class)->purge();
2216
}
2317
}
2418
}

src/Internal/Repository/WalletRepository.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ public function create(array $attributes): Wallet
2929
*/
3030
public function updateBalances(array $data): int
3131
{
32+
// One element gives x10 speedup, on some data
33+
if (count($data) === 1) {
34+
return $this->wallet->newQuery()
35+
->whereKey(key($data))
36+
->update([
37+
'balance' => current($data),
38+
]);
39+
}
40+
3241
$cases = [];
3342
foreach ($data as $walletId => $balance) {
3443
$cases[] = 'WHEN id = ' . $walletId . ' THEN ' . $balance;

0 commit comments

Comments
 (0)