Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make manager registry resettable #1099

Merged
merged 1 commit into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Registry.php
Original file line number Diff line number Diff line change
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) {
Copy link
Contributor

@alexander-schranz alexander-schranz Dec 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alcaeus My array looks like this in 1.12.3:

  ["default"]=>
  string(35) "doctrine.orm.default_entity_manager"

and ends so with:

Doctrine ORM Manager named "doctrine.orm.default_entity_manager" does not exist.

Exception.

any hint how this can happen?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the bin/console debug:container --parameter doctrine.entity_managers does also return it this way

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #1103.

$this->resetManager($managerName);
}
}
}
1 change: 1 addition & 0 deletions Resources/config/dbal.xml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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|^2.0",
"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