File tree 1 file changed +8
-24
lines changed
1 file changed +8
-24
lines changed Original file line number Diff line number Diff line change @@ -72,36 +72,20 @@ public function save(AbstractEntity &$entity): void
72
72
$ entity ->updated_at = new \DateTimeImmutable ();
73
73
$ changedColumns ['updated_at ' ] = DateTimeHelper::dateTimeToString ($ entity ->updated_at );
74
74
}
75
-
76
-
77
75
if ($ this ->config ->hasOptimisticLock ()
78
76
&& method_exists ($ entity , 'getVersion ' )
79
77
&& method_exists ($ entity , 'incrementVersion ' )) {
80
78
$ where ['lock_version ' ] = $ entity ->getVersion ();
81
79
$ entity ->incrementVersion ();
82
80
$ changedColumns ['lock_version ' ] = $ entity ->getVersion ();
83
-
84
- try {
85
- $ connection ->beginTransaction ();
86
- $ versionUpdated = $ connection ->update (
87
- $ this ->getTableName (),
88
- $ changedColumns ,
89
- $ where
90
- );
91
- if (!$ versionUpdated ) {
92
- throw new Exceptions \LockException ('Failed to update entity version, concurrency modification, rolling back. ' );
93
- }
94
- $ connection ->commit ();
95
- } catch (\Throwable $ e ) {
96
- $ connection ->rollBack ();
97
- throw $ e ;
98
- }
99
- } else {
100
- $ connection ->update (
101
- $ this ->getTableName (),
102
- $ changedColumns ,
103
- $ where
104
- );
81
+ }
82
+ $ entityUpdated = $ connection ->update (
83
+ table: $ this ->getTableName (),
84
+ data: $ changedColumns ,
85
+ criteria: $ where ,
86
+ );
87
+ if ($ this ->config ->hasOptimisticLock () && !$ entityUpdated ) {
88
+ throw new Exceptions \LockException ('Failed to update entity version, concurrency modification, rolling back. ' );
105
89
}
106
90
$ entity ->resetChangedColumns ();
107
91
}
You can’t perform that action at this time.
0 commit comments