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

Remove example of register a service where its id match to its class#10070

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

Conversation

@l-vo
Copy link
Contributor

ResolveClassPass which resolve service definitions where class match to the service id is one of the first compiler pass processed (priority 100 in beforeOptimizationPasses phase). When adding a custom compiler pass, it is by default added to the beforeOptimizationPasses but with the default priority of 0. So theResolveClassPass has already been executed and our custom service definition class isn't resolved.

@javiereguiluz
Copy link
Member

@l-vo thanks for your contribution. Sadly I'm having some problems trying to understand the issue here. Are you saying that the current code won't work? That the current code is unnecessary? thanks!

@l-vo
Copy link
ContributorAuthor

@javiereguiluz I think this code won't work in most cases. When the second argument of register isn't set, it's the compiler passResolveClassPass which inject the right class if the service id matchs with a class name. The problem is thatResolveClassPass is processed very early in the container compilation (seeSymfony\Component\DependencyInjection\Compiler\PassConfig).

If I use$container->register(\AppBundle\NumberGenerator::class); in a compiler pass,ResolveClassPass is processed before my own compiler pass and my service class stay not resolved.

Is it clearer ?

javiereguiluz reacted with thumbs up emoji

@javiereguiluz
Copy link
Member

@l-vo it's more clear now. Thanks!

But before merging, let me ask our biggest expert in Dependency Injection to verify this change:@nicolas-grekas Thanks!

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedJul 24, 2018
edited
Loading

I'm fine with this change, calling register can also be done in regular php definition of services, but nobody does that, so that the most common place to do this is in a compiler pass indeed.

@javiereguiluz
Copy link
Member

@l-vo thanks for fixing this error and for the detailed explanations. Also, congrats on your first Symfony Docs contribution!

@javiereguiluzjaviereguiluz merged commit4905190 intosymfony:3.4Jul 30, 2018
javiereguiluz added a commit that referenced this pull requestJul 30, 2018
…to its class (l-vo)This PR was merged into the 3.4 branch.Discussion----------Remove example of register a service where its id match to its class`ResolveClassPass` which resolve service definitions where class match to the service id is one of the first compiler pass processed (priority 100 in beforeOptimizationPasses phase). When adding a custom compiler pass, it is by default added to the beforeOptimizationPasses but with the default priority of 0. So the `ResolveClassPass` has already been executed and our custom service definition class isn't resolved.Commits-------4905190 Remove example of register a service where its id match to its class
@l-vo
Copy link
ContributorAuthor

@javiereguiluz You're welcome ! Thanks :-))

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

3.4

Development

Successfully merging this pull request may close these issues.

4 participants

@l-vo@javiereguiluz@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp