8000 [DependencyInjection] adjust `Autowire` attribute implementation by kbond · Pull Request #45783 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DependencyInjection] adjust Autowire attribute implementation #45783

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
Mar 22, 2022

Conversation

kbond
Copy link
Member
@kbond kbond commented Mar 18, 2022
Q A
Branch? 6.1
Bug fix? no
New feature? yes
Deprecations? no
Tickets #45657 (comment)
License MIT
Doc PR todo

Per discussion with @nicolas-grekas, we've decided to improve the DX of the attribute a bit. The implementation from #45657 still works as described there. This allows for the first Autowire constructor argument to be used for services/expressions by adding a familiar prefix (@ for services, @= for expressions):

class MyService
{
    public function __construct(
        #[Autowire('@some_service')]
        private $service1,

        #[Autowire('@=service("App\\Mail\\MailerConfiguration").getMailerMethod()')
        private $service2,

        #[Autowire('%env(json:file:resolve:AUTH_FILE)%')]
        private $parameter1,
    ) {}
}

@fabpot
Copy link
Member
fabpot commented Mar 22, 2022

Thank you @kbond.

@fabpot fabpot merged commit 12130f4 into symfony:6.1 Mar 22, 2022
@fabpot fabpot mentioned this pull request Apr 15, 2022
wouterj added a commit to symfony/symfony-docs that referenced this pull request May 1, 2022
…attribute (kbond)

This PR was merged into the 6.1 branch.

Discussion
----------

[DependencyInjection][HttpKernel] document `Autowire` attribute

Symfony PRs: symfony/symfony#45657 & symfony/symfony#45783
Closes #16625.
Closes #16636

Commits
-------

bf8be7e Move the autowire attribute sections
f32aec1 [DI][HttpKernel] document `Autowire` attribute
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.

5 participants
0