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

FR: Allow getConfig to traverse nested settings using dot-notation #1803

Closed
simonhamp opened this Issue Feb 24, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@simonhamp

simonhamp commented Feb 24, 2018

Expected behaviour

Nested config would be accessible via dot-notation in an add-on using $this->getConfig('example.setting.key', 'bar') for:

example:
  setting:
    key: foo

Actual behaviour

null is returned.

Steps to reproduce

  1. See above
  2. Have a KitKat
  3. Throw your rubbish in the trash

Server Details

Operating System: Mac OS

Web Server: Laravel Valet

PHP Version: 7.1

Statamic Version: 2.8.7

Updated from an older Statamic or fresh install: Fresh

List of installed addons: Spock, OAuthBridge

Suggestion

Instead of direct array access, consider using array_has($config, $key) and array_get($config, $key) to use Laravel's built-in dot-notation array accessors in Statamic\Extend\Extensible::getConfig(), on L:256 and L:257 respectively.

@jackmcdade

This comment has been minimized.

Member

jackmcdade commented Feb 24, 2018

@simonhamp

This comment has been minimized.

simonhamp commented Feb 24, 2018

@jackmcdade do you mean $this->getConfig('example:setting:key')?

If so, that still returns null for me... :(

@jackmcdade

This comment has been minimized.

Member

jackmcdade commented Feb 28, 2018

Ah you're right. Added for next release 👍

@simonhamp

This comment has been minimized.

simonhamp commented Feb 28, 2018

Awesome. Which method should I use then in readiness: dot-separated or colon-separated?

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented Feb 28, 2018

Go for dots.

@simonhamp simonhamp closed this Mar 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment