Skip to content
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

Binding Arguments by Name or Type for defaults #175

Open
zazoomauro opened this issue May 20, 2022 · 0 comments
Open

Binding Arguments by Name or Type for defaults #175

zazoomauro opened this issue May 20, 2022 · 0 comments
Labels
Milestone

Comments

@zazoomauro
Copy link
Owner

zazoomauro commented May 20, 2022

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,
  ) {}
}
@zazoomauro zazoomauro added this to the 3.0 milestone May 20, 2022
@zazoomauro zazoomauro modified the milestones: 3.0, 3.1 May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant