symfony: sfConfig::get() and max hierarchical levels in yml file

by prettyscripts on 2010-05-03 11:51

phpsymfony

there's limitation on max heirachical levels in yml files when getting values with sfConfig::get().

it's limited to 3 levels. anything more will be returned as array. eg in app.yml:

Code:

all:
  category:
    param1:  value1
    param2:  value2
  category2:
    subcategory:
      param3: value3

to access the values with sfConfig:

PHP:

// to access param1
$param1 sfConfig::get('app_category_param1');
 
// to access 4th level, param3 - wrong!
$param3 sfConfig::get('app_category_subcategory_param3');
 
// to access param3 - the correct way
$params sfConfig::get('app_category_subcategory');
$param3 $params['param3']

what have been defined?

to see all values, call sfConfig::getAll(). this returns array of all defined values.