@@ -38,7 +38,7 @@ public function __construct(Setting $setting, Cache $cache)
3838 */
3939 public function get ($ key , $ default = false )
4040 {
41- $ value = $ this ->getValueFromStore ($ key , $ default );
41+ $ value = $ this ->getValueFromStore ($ key , $ default );
4242 return $ this ->formatValue ($ value , $ default );
4343 }
4444
@@ -50,13 +50,17 @@ public function get($key, $default = false)
5050 */
5151 protected function getValueFromStore ($ key , $ default )
5252 {
53+ $ overrideValue = $ this ->getOverrideValue ($ key );
54+ if ($ overrideValue !== null ) return $ overrideValue ;
55+
5356 $ cacheKey = $ this ->cachePrefix . $ key ;
5457 if ($ this ->cache ->has ($ cacheKey )) {
5558 return $ this ->cache ->get ($ cacheKey );
5659 }
5760
5861 $ settingObject = $ this ->getSettingObjectByKey ($ key );
59- if ($ settingObject !== null ) {
62+
63+ if ($ settingObject !== null ) {
6064 $ value = $ settingObject ->value ;
6165 $ this ->cache ->forever ($ cacheKey , $ value );
6266 return $ value ;
@@ -65,6 +69,10 @@ protected function getValueFromStore($key, $default)
6569 return $ default ;
6670 }
6771
72+ /**
73+ * Clear an item from the cache completely.
74+ * @param $key
75+ */
6876 protected function clearFromCache ($ key )
6977 {
7078 $ cacheKey = $ this ->cachePrefix . $ key ;
@@ -136,9 +144,23 @@ public function remove($key)
136144 * @param $key
137145 * @return mixed
138146 */
139- private function getSettingObjectByKey ($ key )
147+ protected function getSettingObjectByKey ($ key )
140148 {
141149 return $ this ->setting ->where ('setting_key ' , '= ' , $ key )->first ();
142150 }
143151
152+
153+ /**
154+ * Returns an override value for a setting based on certain app conditions.
155+ * Used where certain configuration options overrule others.
156+ * Returns null if no override value is available.
157+ * @param $key
158+ * @return bool|null
159+ */
160+ protected function getOverrideValue ($ key )
161+ {
162+ if ($ key === 'registration-enabled ' && config ('auth.method ' ) === 'ldap ' ) return false ;
163+ return null ;
164+ }
165+
144166}
0 commit comments