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

Appearance settings

[DependencyInjection] Suggestion for autowiring parameters #22755

Copy link
Copy link
@zmitic

Description

@zmitic
Issue body actions
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? yes
Symfony version 3.3

When services are autowired, parameter values still needs to be declared in definition like:

    app.my_service:
        class: AppBundle\Service\MyService
        arguments: 
            - $clientHostParameter: "%client_host%"

What about guessing them based on variable name? For example:

class MyService
{
    public function __construct(TwigEngine $twigEngine, $clientHostParameter)
    {
        //...
    }

So if variable ends with word parameter, S3 would tableize clientHost, look for parameter client_host and inject it.

An example taken from Symfony Flex demo would then become:

class RecipeLoader
{
    public function __construct(LoggerInterface $logger, $kernelDebugParameter)
    {
        //...
    }

What do you think?


Sorry if someone posted this idea before.

TomasVotruba

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.