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

feat: Settings - Decouple from shield #1220

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

najdanovicivan
Copy link

@najdanovicivan najdanovicivan commented Nov 4, 2024

Description
Decouple settings library so it is not required.
Related to #1215

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

Comment on lines +47 to +76

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');
}
}
Copy link
Author

@najdanovicivan najdanovicivan Nov 4, 2024

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.

@najdanovicivan najdanovicivan changed the title WIP: Settings - Decouple from shield WIP feat: Settings - Decouple from shield Nov 4, 2024
@kenjis kenjis added the enhancement New feature or request label Nov 8, 2024
@datamweb datamweb added the GPG-Signing needed Pull requests that need GPG-Signing label Nov 30, 2024
@datamweb datamweb changed the title WIP feat: Settings - Decouple from shield feat: Settings - Decouple from shield Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request GPG-Signing needed Pull requests that need GPG-Signing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants