-
Notifications
You must be signed in to change notification settings - Fork 137
feat: Settings - Decouple from shield #1220
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
base: develop
Are you sure you want to change the base?
feat: Settings - Decouple from shield #1220
Conversation
|
||
if (! function_exists('shieldSetting')) { | ||
/** | ||
* Provides a wrapper function for settings module. | ||
* | ||
* @param mixed $value | ||
* | ||
* @return array|bool|float|int|object|string|void|null | ||
* @phpstan-return ($value is null ? array|bool|float|int|object|string|null : void) | ||
*/ | ||
function shieldSetting(?string $key = null, $value = null) | ||
{ | ||
/** @var AuthConfig $config */ | ||
$config = config('Auth'); | ||
if($config->useSettings) { | ||
return setting($key, $value); | ||
} | ||
|
||
// Getting the value? | ||
if (!empty($key) && count(func_get_args()) === 1) { | ||
$parts = explode('.', $key); | ||
if (count($parts) === 1) { | ||
throw new InvalidArgumentException('$key must contain both the class and field name, i.e. Foo.bar'); | ||
} | ||
return config($parts[0])?->{$parts[1]} ?? null; | ||
} | ||
|
||
throw new InvalidArgumentException('Settings library is not being used for shield'); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the important part. With the proposed change call to setting() method will only occur here.
Yes, it would be great to decouple Shield and Settings packages. Personally, I don't see a lot of sense of having the Settings dependency here, because CodeIgniter already has BaseConfig to handle settings. |
Description
Decouple settings library so it is not required.
Related to #1215
Checklist: