@@ -85,28 +85,31 @@ service('setting')->forget('App.siteName')
8585In addition to the default behavior describe above, ` Settings ` can can be used to define "contextual settings".
8686A context may be anything you want, but common examples are a runtime environment or an authenticated user.
8787In order to use a context you pass it as an additional parameter to the ` get() ` /` set() ` /` forget() ` methods; if
88- a context setting is requested and does not exist then the default global value will be used.
88+ a context setting is requested and does not exist then the general value will be used.
8989
9090Contexts may be any unique string you choose, but a recommended format for supplying some consistency is to
91- given them a category and identifier, like ` environment:production ` or ` group:42 ` .
91+ give them a category and identifier, like ` environment:production ` or ` group:42 ` .
9292
9393An example... Say your App config includes the name of a theme to use to enhance your display. By default
9494your config file specifies ` App.theme = 'default' ` . When a user changes their theme, you do not want this to
9595change the theme for all visitors to the site, so you need to provide the user as the * context* for the change:
9696
9797``` php
98- $context = 'user:' . user_id();
99- service('setting')->set('App.theme', 'dark', $context);
98+ $context = 'user:' . user_id();
99+ service('setting')->set('App.theme', 'dark', $context);
100100```
101101
102102Now when your filter is determining which theme to apply it can check for the current user as the context:
103103
104104``` php
105- $context = 'user:' . user_id();
106- $theme = service('setting')->get('App.theme', $context);
105+ $context = 'user:' . user_id();
106+ $theme = service('setting')->get('App.theme', $context);
107+
108+ // or using the helper
109+ setting()->get('App.theme', $context);
107110```
108111
109- If that context is not found the library falls back to the global value, i.e. ` service('setting')->get('App.theme') `
112+ If that context is not found the library falls back to the general value, i.e. ` service('setting')->get('App.theme') `
110113
111114### Using the Helper
112115
0 commit comments