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

[DependencyInjection] Inherit "public" option when creating aliases with the auto_alias tag#41209

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

Closed
HypeMC wants to merge1 commit intosymfony:5.4fromHypeMC:auto-alias-private

Conversation

@HypeMC
Copy link
Member

QA
Branch?5.x
Bug fix?no
New feature?yes
Deprecations?no
Tickets-
LicenseMIT
Doc PRTODO

Currently when using theauto_alias tag, the aliases created are alwayspublic. With this PR the public option is inherited from the definition:

App\Service\SomeInterface:public:true# The alias inherits the public optiontags:        -{ name: auto_alias, format: '%my_class%' }

$aliasId =$container->getParameterBag()->resolveValue($tag['format']);
if ($container->hasDefinition($aliasId) ||$container->hasAlias($aliasId)) {
$container->setAlias($serviceId,newAlias($aliasId,true));
$container->setAlias($serviceId,newAlias($aliasId,$container->getDefinition($serviceId)->isPublic()));

Choose a reason for hiding this comment

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

this should come with a BC layer that triggers a deprecation when the alias is used as a public one while the target is private

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

@nicolas-grekas Done, ifpublic is not explicitly set it will default totrue and trigger a deprecation. In the future the deprecation can be removed andfalse set as the default.

Choose a reason for hiding this comment

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

I was thinking about something likehttps://symfony.com/blog/new-in-symfony-5-1-deprecate-public-services-into-private-services but for aliases. Not sure how. /cc@fancyweb

@nicolas-grekas
Copy link
Member

Thanks for the PR. I decided to submit#42959 instead. Please have a look.

@HypeMCHypeMC deleted the auto-alias-private branchSeptember 9, 2021 09:35
@HypeMC
Copy link
MemberAuthor

@nicolas-grekas Great, thank you 😄

nicolas-grekas added a commit that referenced this pull requestSep 10, 2021
…ault (nicolas-grekas)This PR was merged into the 5.4 branch.Discussion----------[DependencyInjection] Make auto-aliases private by default| Q             | A| ------------- | ---| Branch?       | 5.4| Bug fix?      | no| New feature?  | no| Deprecations? | yes| Tickets       | -| License       | MIT| Doc PR        | -Replaces#41209Before, this creates a public autoalias:```yaml    app.lock:        tags:            - { name: auto_alias, format: "app.%database_type%_lock" }```After, this creates a public autoalias:```yaml    app.lock:        public: true        tags:            - { name: auto_alias, format: "app.%database_type%_lock" }```Omitting `public: true` will trigger a deprecation warning when the alias is accessed from `$container->get()`. In 6.0, the alias will be private by default if `public: true` is not set.Commits-------679f25e [DependencyInjection] Make auto-aliases private by default
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

3 participants

@HypeMC@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp