Skip to content

Commit

Permalink
Make manager registry resettable
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaeus committed Dec 17, 2019
1 parent b612f15 commit d798dee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Registry.php
Expand Up @@ -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
Expand Down Expand Up @@ -164,4 +165,11 @@ public function getEntityManagerForClass($class)

return $this->getManagerForClass($class);
}

public function reset() : void
{
foreach ($this->getManagerNames() as $managerName) {
$this->resetManager($managerName);
}
}
}
1 change: 1 addition & 0 deletions Resources/config/dbal.xml
Expand Up @@ -63,6 +63,7 @@
<argument>%doctrine.entity_managers%</argument>
<argument>%doctrine.default_connection%</argument>
<argument>%doctrine.default_entity_manager%</argument>
<tag name="kernel.reset" method="reset" />
</service>
<service id="Doctrine\Persistence\ManagerRegistry" alias="doctrine" public="false" />
<service id="Doctrine\Common\Persistence\ManagerRegistry" alias="doctrine" public="false" />
Expand Down
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -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",
Expand Down

0 comments on commit d798dee

Please sign in to comment.