Skip to content

Commit f1fc2ef

Browse files
author
ruff
committed
Added configuration option -> Enable transactions in config/orion.php, Disabled by default
1 parent af2e13a commit f1fc2ef

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

config/orion.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@
2828
['url' => env('APP_URL').'/api', 'description' => 'Default Environment'],
2929
],
3030
],
31+
'transactions' => [
32+
'enabled' => false,
33+
],
3134
];

src/Concerns/HandlesTransactions.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,14 @@
66

77
trait HandlesTransactions
88
{
9-
/**
10-
* Flag to enable or disable transactions
11-
*
12-
* @var boolean
13-
*/
14-
protected $transactionsEnabled = false;
15-
169
/**
1710
* Start database transaction
1811
*
1912
* @return void
2013
*/
2114
protected function startTransaction(): void
2215
{
23-
if ($this->transactionsEnabled !== true) {
16+
if ($this->transactionsAreEnabled() !== true) {
2417
return;
2518
}
2619

@@ -35,7 +28,7 @@ protected function startTransaction(): void
3528
*/
3629
protected function commitTransaction(): void
3730
{
38-
if ($this->transactionsEnabled !== true) {
31+
if ($this->transactionsAreEnabled() !== true) {
3932
return;
4033
}
4134

@@ -50,7 +43,7 @@ protected function commitTransaction(): void
5043
*/
5144
protected function rollbackTransaction(): void
5245
{
53-
if ($this->transactionsEnabled !== true) {
46+
if ($this->transactionsAreEnabled() !== true) {
5447
return;
5548
}
5649

@@ -72,4 +65,14 @@ protected function rollbackTransactionAndRaise(\Exception $exception): void
7265

7366
throw $exception;
7467
}
68+
69+
/**
70+
* Return configuration value
71+
*
72+
* @return boolean
73+
*/
74+
protected function transactionsAreEnabled(): bool
75+
{
76+
return (bool)config('orion.transactions.enabled', false);
77+
}
7578
}

0 commit comments

Comments
 (0)