Skip to content

Binding Arguments by Name or Type for defaults #175

Open
@zazoomauro

Description

@zazoomauro

Bind keyword to bind specific arguments by name or type:

or in pure js or typescript

const compiler = new ContainerBuilder(false, '../path/to/src')
compiler.addBind('adminEmail', 'manager@example.com')
compiler.addBind('someParameter', process.env.SOME_PARAMETER)
const autowire = new Autowire(compiler)

or in yaml

services:
    _defaults:
        bind:
            # pass this value to any adminEmail argument for any service
            # that's defined in this file (including controller arguments)
            adminEmail: 'manager@example.com'

            # also if is coming from environment variables
            someParameter: '%env(SOME_PARAMETER)%'

Then you can use it it that way

export default class SomeService() {
  constructor(
    private readonly adminEmail: string,
    private readonly someParameter: string,
  ) {}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions