Skip to content

Autowiring container parameters is not supported #6357

@DieterHolvoet

Description

@DieterHolvoet

Describe the bug
For a contrib Drush command I tried autowiring a container parameter using the Autowire attribute, but it seems like this is not supported.

To Reproduce
After adding this attribute, the command class is no longer being discovered.

Expected behavior
The command class is discovered and the parameter is injected.

Actual behavior
AutowireTrait considers the parameter name a service name. I tried to change AutowireTrait to support this, but so far I haven't found an easy way since League\Container\Container doesn't have getParameter/hasParameter methods.

Workaround
Inject Symfony\Component\DependencyInjection\ContainerInterface and get the parameter from there in the constructor.

System Configuration

Q A
Drush version? 13.4.0-rc1
Drupal version? 11.1.4
PHP version 8.3.1
OS? Mac

Additional information
/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions