getkirby / ideas

This is the backlog of ideas and feature requests from the last two years. Use our new feedback platform to post your new ideas or vote on existing ideas.
https://feedback.getkirby.com
20 stars 0 forks source link

[Cms] Namespaced options as array instead of dot-notation #32

Closed ghost closed 5 years ago

ghost commented 6 years ago

@jenstornell commented on Jul 27, 2018, 4:46 AM UTC:

In the options in config/config.php, currently what we do is this:

return [
    'jenstornell.robots.content' => 'testing',
    'jenstornell.ga.id' => '12345',
    'jenstornell.ga.debug' => true,
];

It works fine, but I'm very tempted to instead write something like this:

return [
    'jenstornell' => [
        'robots' => [
            'content' => 'testing'
        ],
        'ga' => [
            'id' => '12345',
            'debug' => true,
        ]
    ],
];

The big difference is that the last version is DRY. If the namespace or the plugin name is changed, I can just change it in one place.

Also plugins with the same author will be nicely grouped together when they use the same namespace.

This issue was moved by bastianallgeier from k-next/kirby#761.

ghost commented 6 years ago

@bnomei commented on Jul 27, 2018, 5:32 AM UTC:

(removed my post since i missunderstood question) XD

ghost commented 6 years ago

@bnomei commented on Jul 27, 2018, 7:47 PM UTC:

not totally unrelated to DRY is total length of config files. splitting them based on plugin etc. but rejoice – for which there is a solution:

k-next/plugins#21 (comment)

ghost commented 6 years ago

@distantnative commented on Aug 24, 2018, 9:28 AM UTC:

Related #604

ghost commented 6 years ago

@omz13 commented on Sep 1, 2018, 6:27 PM UTC:

FWIW, in the latest release of my xmlsitemap I implemented a single-level pseudo-namespace. The readme gives an example. The more interesting bit of code is below. With some recursion it could probably be extended to support multiple levels of namespace.

https://github.com/omz13/kirby3-xmlsitemap/blob/757b4130ce1ef5547f79c2ecf2a1a187b0618df1/src/xmlsitemap.php#L61-L78

bnomei commented 5 years ago

i just ran into this inconsistency again but the other way around – trying to write core options like plugin options. it would be nice if both ways would work. it boils down to just imploding recursively with a ., right?

https://getkirby.com/docs/reference/system/options/session

<?php
return [
    'session.cookieName' => 'kirby_session', // will fail since using plugin syntax
    'session' => [ // will work for since its not a plugin
        'cookieName' => 'kirby_session',
    ]
];
bnomei commented 5 years ago

i just ran into this inconsistency again but the other way around – trying to write core options like plugin options. it would be nice if both ways would work. it boils down to just imploding recursively with a ., right?

https://getkirby.com/docs/reference/system/options/session

<?php
return [
    'session.cookieName' => 'kirby_session', // will fail since using plugin syntax
    'session' => [ // will work for since its not a plugin
        'cookieName' => 'kirby_session',
    ]
];
bastianallgeier commented 5 years ago

This is now solved!