-
Notifications
You must be signed in to change notification settings - Fork 34
Parameters
Mauro Gadaleta edited this page Jun 6, 2017
·
2 revisions
Use the parameters section of a config file to set parameters:
parameters:
mailer.transport: sendmail
You can refer to parameters elsewhere in any config file by surrounding them with percent (%
) signs, e.g. %mailer.transport%
.
parameters:
mailer.transport: sendmail
services:
app.mailer:
class: ./App/Mailer
arguments: ['%mailer.transport%']
Working with container parameters is straightforward using the container's accessor methods for parameters:
import {ContainerBuilder} from 'node-dependency-injection'
let container = new ContainerBuilder()
if (container.hasParameter('mailer.transport')) {
// ...
}
let mailerTransport = container.getParameter('mailer.transport')
// add a new parameter
container.setParameter('mailer.transport', 'sendmail')
Parameters do not need to be flat strings, they can also contain array values. For example
parameters:
my_mailer.gateways: [mail1, mail2, mail3]
my_multilang.language_fallback:
en:
- en
- fr
fr:
- fr
- en
Parameters can also be complex like objects.
For Example
parameters:
complex_parameter:
foo: bar
bar: foo
Copyright © 2023-2024 Mauro Gadaleta