Skip to content

Parameters

Mauro Gadaleta edited this page Jun 6, 2017 · 2 revisions

Parameters

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%']

Getting and Setting Container Parameters in JavaScript

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')

Array Parameters

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

Object Parameters

Parameters can also be complex like objects.

For Example

YAML
parameters:
	complex_parameter:
		foo: bar
		bar: foo