Development

#2130 (Curious note on YAML array representation)

You must first sign up to be able to contribute.

Ticket #2130 (closed enhancement: wontfix)

Opened 1 year ago

Last modified 1 year ago

Curious note on YAML array representation

Reported by: Rihad.Haciyev Assigned to: fabien
Priority: minor Milestone:
Component: configuration Version: 1.0.5
Keywords: Cc:
Qualification: Unreviewed

Description

YAML parses containments up to 2 levels deep as "scalars", 3 levels and more turn it into array:

all:
  one:
    two_with_or_without_underscores: on
    anothertwo: on

results in:

sfConfig::add(array(
  'app_one_two_with_or_without_underscores' => true,
  'app_one_anothertwo' => true,

but

all:
  one:
    two:
      three: on
      anotherthree: on

becomes

sfConfig::add(array(
  'app_one_two' => array (
    'three' => true,
    'anotherthree' => true,
  ),

Is there any reason for settings to *ever* become arrays? I think offhand that keeping setting names as strings (such as app_one_two_three) no matter how "deep" it lies is much more flexible, allowing more fine-grained settings overriding. Perhaps there's something I didn't think about, but the benefits are exhaustive.

Change History

08/23/07 16:31:49 changed by Rihad.Haciyev

In addition it's barely convenient to get at a deep setting value: currently sfConfig::get('app_one_two_three') won't work if it's dealing with arrays.

08/25/07 01:12:32 changed by Andrejs.Verza

My opinion is that it is not that simple.

I have experienced both cases, where arrays were more flexible than strings, and - the opposite - where strings would be preferable.

I believe, the developers have found some compromise between those both cases and the core performance.

Still I have managed to arrange YAML keys so that they can be accessed in a convenient way.

08/25/07 17:15:37 changed by Rihad.Haciyev

I think this real-life example will suffice it to bury all objections:

all:
  auth:
#   Currently this approach won't let you use e.g. sfConfig::get('app_auth_cookie_enabled'):
#   cookie:
#     enabled: yes
#     lifetime: <?php echo 86400*15, "\n" ?>
#   instead you must use this:
    cookie_enabled: yes
    cookie_lifetime: <?php echo 86400*15, "\n" ?>

12/26/07 22:51:05 changed by fabien

  • status changed from new to closed.
  • resolution set to wontfix.
  • qualification set to Unreviewed.