From d798deea8cf9c0d9874c717134e42db094caa5a0 Mon Sep 17 00:00:00 2001 From: Andreas Braun Date: Tue, 17 Dec 2019 22:12:17 +0100 Subject: [PATCH] Make manager registry resettable --- Registry.php | 10 +++++++++- Resources/config/dbal.xml | 1 + composer.json | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Registry.php b/Registry.php index a80be6174..4f28cace2 100644 --- a/Registry.php +++ b/Registry.php @@ -7,11 +7,12 @@ use Psr\Container\ContainerInterface; use Symfony\Bridge\Doctrine\ManagerRegistry; use Symfony\Bridge\Doctrine\RegistryInterface; +use Symfony\Contracts\Service\ResetInterface; /** * References all Doctrine connections and entity managers in a given Container. */ -class Registry extends ManagerRegistry implements RegistryInterface +class Registry extends ManagerRegistry implements RegistryInterface, ResetInterface { /** * @param string[] $connections @@ -164,4 +165,11 @@ public function getEntityManagerForClass($class) return $this->getManagerForClass($class); } + + public function reset() : void + { + foreach ($this->getManagerNames() as $managerName) { + $this->resetManager($managerName); + } + } } diff --git a/Resources/config/dbal.xml b/Resources/config/dbal.xml index 8dbb7844d..8da088d2a 100644 --- a/Resources/config/dbal.xml +++ b/Resources/config/dbal.xml @@ -63,6 +63,7 @@ %doctrine.entity_managers% %doctrine.default_connection% %doctrine.default_entity_manager% + diff --git a/composer.json b/composer.json index 3a558efda..f9b763eab 100644 --- a/composer.json +++ b/composer.json @@ -32,6 +32,7 @@ "jdorn/sql-formatter": "^1.2.16", "symfony/cache": "^3.4.30|^4.3.3", "symfony/config": "^3.4.30|^4.3.3", + "symfony/service-contracts": "^1.1.1", "symfony/console": "^3.4.30|^4.3.3", "symfony/dependency-injection": "^3.4.30|^4.3.3", "symfony/doctrine-bridge": "^3.4.30|^4.3.3",