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] Add Lazy attribute for classes and arguments#52922

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:7.1fromTiriel:lazy-attribute
Feb 3, 2024

Conversation

@Tiriel
Copy link
Contributor

QA
Branch?7.1
Bug fix?no
New feature?yes
Deprecations?no
Issues#
LicenseMIT

This commit adds a Lazy attribute shortcut for service definitions. The goal here is simply to improve the DX with a single attribute for lazy loaded services, while adding the strict minimum amount of new code.
This attribute can be used as a replacement for theAutowire(lazy: bool|string) attribute on any autowired argument or for theAutoconfigure(lazy: bool|string) attribute on an class definition. Both use case support an optional parameter to specify with class/interface should be used for the proxy.

Usage on a class:

useSymfony\Component\DependencyInjection\Attribute\Lazy;#[Lazy]class LazyLoaded{// ...}

On a method argument:

useSymfony\Component\DependencyInjection\Attribute\Lazy;class SuperAwesomeService{publicfunction__construct(#[Lazy]SomeOtherService$service)    {// ...    }}

7-zete-7 reacted with thumbs up emoji
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment
edited
Loading

Choose a reason for hiding this comment

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

This made me wonder whether this blurs any lines but I think I'm good with the proposal.
The implementation should be updated to forbid using both Lazy and Autowire since on the attribute is not repeatable.

Tiriel reacted with thumbs up emoji
@Tiriel
Copy link
ContributorAuthor

Tiriel commentedJan 8, 2024
edited by nicolas-grekas
Loading

The implementation should be updated to forbid using both Lazy and Autowire since on the attribute is not repeatable.

Going to work on this asap, thanks!

@TirielTirielforce-pushed thelazy-attribute branch 2 times, most recently from25cc0f4 to091395aCompareJanuary 11, 2024 16:56
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

LGTM but CS, see also fabbot

@fabpot
Copy link
Member

Thank you@Tiriel.

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

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@dunglasdunglasAwaiting requested review from dunglasdunglas is a code owner

+1 more reviewer

@stloydstloydstloyd left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

7.1

Development

Successfully merging this pull request may close these issues.

5 participants

@Tiriel@fabpot@stloyd@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp