-
Notifications
You must be signed in to change notification settings - Fork 23
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
Contexts #16
Conversation
The BC check failure is expected, as noted. |
src/Handlers/DatabaseHandler.php
Outdated
@@ -142,7 +163,7 @@ private function hydrate() | |||
$rawValues = db_connect()->table($this->table)->get(); |
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.
I think our hydration system and caching system will need to change. If we have thousands of users in the system we don't want to load all of their individual settings into the system at once. I would recommend that hydrate
could take the $context
. If present it caches it locally under the context name, otherwise keeps another cache for non-context settings.
private $settings = [
'general' => [],
'contexts' => []
];
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.
Good idea!
If I define a contraint that does not match, but have a default value defined in a config file, will On the same note: |
That's correct. It is a cascading check, so if you supply a context then the return is "setting with context > setting without context > Config value > null". I tried to make this clear in the README:
@sfadschm Did you miss that, or did you read that and still found it confusing? |
Miss... |
This PR expands the core function to add a new feature: contexts. A "contextual setting" is a way of defining a setting for a specific subset of circumstances, left to the developer to define (see #15 (comment)). Contextual settings fall back on their "global" version (i.e. the current behavior), providing one more layer of customizability. An example of a contextual setting might be environment-specific URLs:
In order to facilitate detection of "hits" versus "misses" this PR also adds the
has()
method to handlers to determine whether a value is present or not. This expands onnull
value support, since we can now differentiate between "nonexistent" and "present but null".Note: Because this feature modifies an abstract method definition it will require a major release.