4

Here is what I want to do. I've got some yml file like...

My custom yml file :

# app/config/sv_parameters.yml
parameters:
  sv_email:
    debug: "debug@debug.com"
    admin: "admin@admin.com"
    ...

The config.yml file, importing my custom params :

# app/config/config.yml
imports:
  - { resource: sv_parameters.yml }
...

The config_dev.yml, importing the config.yml, and using a sub-parameter of my custom yml file :

# app/config/config_dev.yml
imports:
- { resource: config.yml }

swiftmailer:
  delivery_address: "%sv_email.debug%"

But, when I clear:cache :

You have requested a non-existent parameter "sv_email.debug".

I know in PHP multi-level parameters are arrays. But does that mean we can access them in pure YML ?

I could write my sv_email parameters inline, but that's not as clean as multi levels..

Bonswouar
  • 1,521
  • 2
  • 17
  • 37

1 Answers1

2

This is not possible to achieve in YML.
You have to move this nested variable to the upper level and then - include it in both needed places.

Vitalii Zurian
  • 17,858
  • 4
  • 64
  • 81
  • That's what I thought.. Do they plan to implement it in YML ? Because it would be much cleaner sometimes, instead of repeating `sv_email.debug` `sv_email.admin` `sv_email.client` ... – Bonswouar Aug 28 '13 at 13:15
  • @Bonswouar I have absolutely no idea :) – Vitalii Zurian Aug 28 '13 at 13:32
  • 1
    No chance. . is allowed in yaml parameters names so sv_email.client : value works just fine. Just no way to convert arrays to a dot notation without a massive bc break. – Cerad Aug 28 '13 at 14:53
  • On the other hand, the Symfony:DependencyInjection::load method allows you to add parameters to your container. So you could convert sv_email into individual parameters if you want. But I suspect you may find that to be more trouble than it's worth. – Cerad Aug 28 '13 at 14:56