Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bridge/Doctrine] Reset the EM lazy-proxy instead of the EM service#19203

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfromnicolas-grekas:lazy-reset
Jul 1, 2016

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekasnicolas-grekas commentedJun 28, 2016
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?yes
Tests pass?no
Fixed tickets-
LicenseMIT
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

}
$manager->setProxyInitializer(
function (&$wrappedInstance,LazyLoadingInterface$manager)use ($name) {
$this->container->set($name,null);
Copy link
Member

Choose a reason for hiding this comment

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

this does not solve the issue, as it is what will be deprecated

@stof
Copy link
Member

Status: needs work

@nicolas-grekas
Copy link
MemberAuthor

Updated
Status: needs review

if (isset($this->aliases[$name =strtolower($name)])) {
$name =$this->aliases[$name];
}
$method ='get'.strtr($name,$this->underscoreMap).'Service';
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it possible instead to access the container methods map ?

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW i guess we should somehow deprecate using another container than the one provided by symfony ?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Method maps is now used also. We already are enforcing a symfony container, see type hint onContainerAwareTrait::setContainer

Copy link
Contributor

Choose a reason for hiding this comment

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

Of course but the type hint istargeting the interface, and we can't know its internals.

@nicolas-grekasnicolas-grekasforce-pushed thelazy-reset branch 2 times, most recently from2efb9d2 to0315985CompareJune 29, 2016 07:43
@nicolas-grekas
Copy link
MemberAuthor

nicolas-grekas commentedJun 29, 2016
edited
Loading

Implementation details & discussion following @Ener-Getickcomments:

the$container property is of typeContainerInterface but this interface doesn't provide any mean to get access to proxy initializers used for lazy services instanciation. My stand in this PR is that it is fine in this very case to get over the public interfaces and use the protected properties directly: the bridge is a Symfony managed package so that we have all the required tests & ci to ensure we won't break anything in the long run.
As far as custom container implementations are used into the wild, they should still be supported if they use the protected properties as expected. If this really exists (a custom incompatible container that generates LazyProxyInterfaces services), we can think later of new interfaces to allow what we're doing here but using public methods.

Yet, I think it's just fine to do direct access. Let's be pragmatic.

GuilhemN reacted with thumbs up emoji

@stof
Copy link
Member

@nicolas-grekas would be great to debug CI failures

@nicolas-grekas
Copy link
MemberAuthor

@stof see#19217 (btw, votes welcomed on both this and that PRs ;) )

@fabpot
Copy link
Member

Thank you@nicolas-grekas.

@fabpotfabpot merged commitc581cd4 intosymfony:masterJul 1, 2016
fabpot added a commit that referenced this pull requestJul 1, 2016
…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#19192Ping@stofCommits-------c581cd4 [Bridge/Doctrine] Reset the EM lazy-proxy instead of the EM service
@stof
Copy link
Member

@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.

@gregoirepaqueron
Copy link

How to set entity managers lazy by default doctrine configuration ?

My conf :

doctrine:orm:auto_generate_proxy_classes:"%kernel.debug%"default_entity_manager:defaultentity_managers:sso:connection:ssomappings:GsoiJNumAdminMainBundle:type:"annotation"dir:"Entity/SSO"prefix:"MyPrefix\\Entity\\SSO"

When i want to reset the manager, i got the deprecation message :
User Deprecated: Resetting a non-lazy manager service is deprecated since Symfony 3.2 and will throw an exception in version 4.0. Set the "doctrine.orm.sso_entity_manager" service as lazy and require "symfony/proxy-manager-bridge" in your composer.json file instead.

with this code :

$this->container->get('doctrine')->resetManager('sso');

@stof
Copy link
Member

installocramius/proxy_manager so that a proxy can be generated to actually make the service lazy (requiring the bridge itself won't do the trick when using the fullstack repo as it replaces the bridge but does not enforce installing the library).
DoctrineBundle already marks the service as lazy (if you use the latest version of the bundleà

gregoirepaqueron reacted with thumbs up emoji

@gregoirepaqueron
Copy link

Thank you@stof for your explanation!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@nicolas-grekas@stof@fabpot@gregoirepaqueron@GuilhemN@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp