DDC-4022 deduplication of internal UnitOfWork methods
the methods UnitOfWork#afterTransactionRolledBack() and UnitOfWork#afterTransactionComplete do almost the same, so it can be abstracted into another private method.
This commit is contained in:
parent
3c3b7364ba
commit
c337f8f5c7
@ -3259,21 +3259,9 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
*/
|
*/
|
||||||
private function afterTransactionComplete()
|
private function afterTransactionComplete()
|
||||||
{
|
{
|
||||||
if ( ! $this->hasCache) {
|
$this->doAfterTransaction(function (CachedPersister $persister) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->persisters as $persister) {
|
|
||||||
if ($persister instanceof CachedPersister) {
|
|
||||||
$persister->afterTransactionComplete();
|
$persister->afterTransactionComplete();
|
||||||
}
|
});
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->collectionPersisters as $persister) {
|
|
||||||
if ($persister instanceof CachedPersister) {
|
|
||||||
$persister->afterTransactionComplete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3281,19 +3269,23 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
*/
|
*/
|
||||||
private function afterTransactionRolledBack()
|
private function afterTransactionRolledBack()
|
||||||
{
|
{
|
||||||
if ( ! $this->hasCache) {
|
$this->doAfterTransaction(function (CachedPersister $persister) {
|
||||||
|
$persister->afterTransactionRolledBack();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs an action after the transaction.
|
||||||
|
*/
|
||||||
|
private function doAfterTransaction(callable $callback)
|
||||||
|
{
|
||||||
|
if (!$this->hasCache) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->persisters as $persister) {
|
foreach (array_merge($this->persisters, $this->collectionPersisters) as $persister) {
|
||||||
if ($persister instanceof CachedPersister) {
|
if ($persister instanceof CachedPersister) {
|
||||||
$persister->afterTransactionRolledBack();
|
call_user_func($callback, $persister);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->collectionPersisters as $persister) {
|
|
||||||
if ($persister instanceof CachedPersister) {
|
|
||||||
$persister->afterTransactionRolledBack();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user