@@ -416,9 +416,7 @@ public function setDocumentPersister(string $documentName, Persisters\DocumentPe
416
416
public function commit (array $ options = []): void
417
417
{
418
418
// Raise preFlush
419
- if ($ this ->evm ->hasListeners (Events::preFlush)) {
420
- $ this ->evm ->dispatchEvent (Events::preFlush, new Event \PreFlushEventArgs ($ this ->dm ));
421
- }
419
+ $ this ->evm ->dispatchEvent (Events::preFlush, new Event \PreFlushEventArgs ($ this ->dm ));
422
420
423
421
// Compute changes done since last commit.
424
422
$ this ->computeChangeSets ();
@@ -448,9 +446,7 @@ public function commit(array $options = []): void
448
446
}
449
447
450
448
// Raise onFlush
451
- if ($ this ->evm ->hasListeners (Events::onFlush)) {
452
- $ this ->evm ->dispatchEvent (Events::onFlush, new Event \OnFlushEventArgs ($ this ->dm ));
453
- }
449
+ $ this ->evm ->dispatchEvent (Events::onFlush, new Event \OnFlushEventArgs ($ this ->dm ));
454
450
455
451
foreach ($ this ->getClassesForCommitAction ($ this ->documentUpserts ) as $ classAndDocuments ) {
456
452
[$ class , $ documents ] = $ classAndDocuments ;
@@ -473,9 +469,7 @@ public function commit(array $options = []): void
473
469
}
474
470
475
471
// Raise postFlush
476
- if ($ this ->evm ->hasListeners (Events::postFlush)) {
477
- $ this ->evm ->dispatchEvent (Events::postFlush, new Event \PostFlushEventArgs ($ this ->dm ));
478
- }
472
+ $ this ->evm ->dispatchEvent (Events::postFlush, new Event \PostFlushEventArgs ($ this ->dm ));
479
473
480
474
// Clear up
481
475
$ this ->documentInsertions =
@@ -2437,10 +2431,6 @@ public function clear(?string $documentName = null): void
2437
2431
}
2438
2432
}
2439
2433
2440
- if (! $ this ->evm ->hasListeners (Events::onClear)) {
2441
- return ;
2442
- }
2443
-
2444
2434
$ this ->evm ->dispatchEvent (Events::onClear, new Event \OnClearEventArgs ($ this ->dm , $ documentName ));
2445
2435
}
2446
2436
0 commit comments