Reveclair
Reveclair

Reputation: 2421

How to have an array in a parameter file?

I'm using Symfony2.1 and I need to save an array in a config/parameter file because I would modify the content of this array often (probably once every 6 months) (it contains email addresses).

I know that I can save a string in parameters.yml for example using :

in app/config/parameters.yml

parameters
    address: '[email protected]'

and retrieving this parameter using $this->container->getParameter('address') in a controller, but I have many recipients and I would like to have something like :

    parameters
        address: array('[email protected]', '[email protected]', '[email protected])
#the number of addresses is actually not defined

Upvotes: 0

Views: 1153

Answers (1)

Rufinus
Rufinus

Reputation: 30741

Yaml syntax for arrays would be:

address: 
    - [email protected]
    - [email protected]
    - example3@domain

or

address: ["[email protected]", "[email protected]"]

but i dont know if symfony supports this.

Upvotes: 1

Related Questions