Removed auto-flushing for every event from EventManager.

This commit is contained in:
Vassyli
2018-10-05 15:57:30 +02:00
committed by Basilius Sauter
parent 8a75e81431
commit c07f7b3342
4 changed files with 8 additions and 2 deletions
+2 -1
View File
@@ -111,7 +111,8 @@ class EventManager
'class' => $class,
'library' => $library
]);
$e->save($this->g->getEntityManager());
$this->g->getEntityManager()->persist($e);
}
/**
+2 -1
View File
@@ -79,7 +79,8 @@ class ModuleManager
try {
$class::onRegister($this->g, $m);
$m->save($this->g->getEntityManager());
$this->g->getEntityManager()->persist($m);
$this->g->getEntityManager()->flush();
} catch (Throwable $e) {
$this->g->getLogger()->error("Calling {$class}::onRegister failed with exception: {$e->getMessage()}");
unset($m);
+1
View File
@@ -96,6 +96,7 @@ class EventManagerTest extends CoreModelTestCase
$library = 'lotgd/tests';
$em->subscribe($pattern, $class, $library);
$this->getEntityManager()->flush();
$sub = EventSubscription::create([
'pattern' => $pattern,
+3
View File
@@ -159,6 +159,7 @@ class GameTest extends CoreModelTestCase
$this->g->getEventManager()->subscribe('/h\/lotgd\/core\/default-scene/', DefaultSceneProvider::class, 'lotgd/core/tests');
$this->g->getEventManager()->subscribe('/h\/lotgd\/core\/navigate-to\/.*/', DefaultSceneProvider::class, 'lotgd/core/tests');
$this->getEntityManager()->flush();
$v = $this->g->getViewpoint();
// Run it twice to make sure no additional DB operations happen.
@@ -214,6 +215,7 @@ class GameTest extends CoreModelTestCase
// subscribe event
$this->g->getEventManager()->subscribe('#h/lotgd/core/navigate-to/lotgd/tests/paramaters#', DefaultSceneProvider::class, 'lotgd/core/tests');
$this->getEntityManager()->flush();
$action = new Action(7, null, ["foo" => "baz"]);
$actionId = $action->getId();
@@ -243,6 +245,7 @@ class GameTest extends CoreModelTestCase
// subscribe event
$this->g->getEventManager()->subscribe('#h/lotgd/core/navigate-to/lotgd/tests/paramaters#', DefaultSceneProvider::class, 'lotgd/core/tests');
$this->getEntityManager()->flush();
$action = new Action(7, null, ["foo" => "baz"]);
$actionId = $action->getId();