Skip to content

do never fetch private services from the container #9157

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

Merged
merged 1 commit into from
Jan 29, 2018

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Jan 28, 2018

Explaining that private services can still be fetched from the container
under certain circumstances does not look like a good idea. Not only is
it hard to grasp for beginners to understand why this sometimes works.
It also becomes a real problem when upgrading to Symfony 4 where all
private services won't be retrievable from the container through service
location.

Explaining that private services can still be fetched from the container
under certain circumstances does not look like a good idea. Not only is
it hard to grasp for beginners to understand why this sometimes works.
It also becomes a real problem when upgrading to Symfony 4 where all
private services won't be retrievable from the container through service
location.
@@ -57,12 +57,11 @@ What makes private services special is that, if they are only injected once,
they are converted from services to inlined instantiations (e.g. ``new PrivateThing()``).
This increases the container's performance.

Now that the service is private, you *should not* fetch the service directly
Now that the service is private, you *must not* fetch the service directly
Copy link
Member

Choose a reason for hiding this comment

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

Ideally I'd like to say: "you can't fetch..." but since you can or cannot depending on some other circumstances, I guess your reword is the best we can do for now.

@javiereguiluz
Copy link
Member

Thanks Christian.

@javiereguiluz javiereguiluz merged commit fedc522 into symfony:2.7 Jan 29, 2018
javiereguiluz added a commit that referenced this pull request Jan 29, 2018
This PR was merged into the 2.7 branch.

Discussion
----------

do never fetch private services from the container

Explaining that private services can still be fetched from the container
under certain circumstances does not look like a good idea. Not only is
it hard to grasp for beginners to understand why this sometimes works.
It also becomes a real problem when upgrading to Symfony 4 where all
private services won't be retrievable from the container through service
location.

Commits
-------

fedc522 do never fetch private services from the container
@xabbuh xabbuh deleted the issue-6959 branch January 29, 2018 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants