[Bridge/Doctrine] Reset the EM lazy-proxy instead of the EM service#19203
[Bridge/Doctrine] Reset the EM lazy-proxy instead of the EM service#19203fabpot merged 1 commit intosymfony:masterfrom
Conversation
bcfdac7 to
f5287aa
Compare
| } | ||
| $manager->setProxyInitializer( | ||
| function (&$wrappedInstance, LazyLoadingInterface $manager) use ($name) { | ||
| $this->container->set($name, null); |
There was a problem hiding this comment.
this does not solve the issue, as it is what will be deprecated
|
Status: needs work |
f5287aa to
7444ccc
Compare
|
Updated |
358a6bf to
6bfdb82
Compare
| if (isset($this->aliases[$name = strtolower($name)])) { | ||
| $name = $this->aliases[$name]; | ||
| } | ||
| $method = 'get'.strtr($name, $this->underscoreMap).'Service'; |
There was a problem hiding this comment.
Isn't it possible instead to access the container methods map ?
There was a problem hiding this comment.
BTW i guess we should somehow deprecate using another container than the one provided by symfony ?
There was a problem hiding this comment.
Method maps is now used also. We already are enforcing a symfony container, see type hint on ContainerAwareTrait::setContainer
There was a problem hiding this comment.
Of course but the type hint is targeting the interface, and we can't know its internals.
2efb9d2 to
0315985
Compare
|
Implementation details & discussion following @Ener-Getick comments: the Yet, I think it's just fine to do direct access. Let's be pragmatic. |
|
@nicolas-grekas would be great to debug CI failures |
0315985 to
c112dc0
Compare
c112dc0 to
c581cd4
Compare
|
Thank you @nicolas-grekas. |
…he EM service (nicolas-grekas) This PR was merged into the 3.2-dev branch. Discussion ---------- [Bridge/Doctrine] Reset the EM lazy-proxy instead of the EM service | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | no | Fixed tickets | - | License | MIT | Doc PR | - This makes the entity manager resettable by resetting its proxy, which should be more robust than resetting its service. See first comments in #19192 Ping @stof Commits ------- c581cd4 [Bridge/Doctrine] Reset the EM lazy-proxy instead of the EM service
|
@nicolas-grekas you forgot the second half of this task: opening a PR on DoctrineBundle to mark the EM services as lazy so that a proxy is generated for them. |
|
How to set entity managers lazy by default doctrine configuration ? My conf : doctrine:
orm:
auto_generate_proxy_classes: "%kernel.debug%"
default_entity_manager: default
entity_managers:
sso:
connection: sso
mappings:
GsoiJNumAdminMainBundle:
type: "annotation"
dir: "Entity/SSO"
prefix: "MyPrefix\\Entity\\SSO"When i want to reset the manager, i got the deprecation message : with this code : $this->container->get('doctrine')->resetManager('sso'); |
|
install |
|
Thank you @stof for your explanation! |
This makes the entity manager resettable by resetting its proxy, which should be more robust than resetting its service.
See first comments in #19192
Ping @stof