Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jenstornell opened this issue Jul 27, 2018 · 5 comments
Closed

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

jenstornell opened this issue Jul 27, 2018 · 5 comments

Comments

@jenstornell
Copy link

jenstornell commented Jul 27, 2018

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.

@bnomei
Copy link

bnomei commented Jul 27, 2018

(removed my post since i missunderstood question) XD

@bnomei
Copy link

bnomei commented Jul 27, 2018

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:

https://github.com/k-next/plugins/issues/21#issuecomment-408519265

@distantnative distantnative added type: enhancement ✨ Suggests an enhancement; improves Kirby type: idea 💡 and removed type: enhancement ✨ Suggests an enhancement; improves Kirby labels Jul 28, 2018
@distantnative distantnative changed the title [Cms] Options as array? [Cms] Namespaced options as array instead of dot-notation Jul 28, 2018
@distantnative
Copy link
Member

Related #604

@omz13
Copy link

omz13 commented Sep 1, 2018

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

@ghost
Copy link

ghost commented Oct 25, 2018

This issue was moved by bastianallgeier to k-next/ideas#32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants