PHP Class BookStack\Services\SettingService

The settings are a simple key-value database store.
Show file Open project: ssddanbrown/bookstack

Protected Properties

Property Type Description
$cache
$cachePrefix
$setting

Public Methods

Method Description
__construct ( Setting $setting, Illuminate\Contracts\Cache\Repository $cache ) SettingService constructor.
get ( $key, string | boolean $default = false ) : boolean | string Gets a setting from the database, If not found, Returns default, Which is false by default.
has ( $key ) : boolean Checks if a setting exists.
put ( $key, $value ) : boolean Add a setting to the database.
remove ( $key ) : boolean Removes a setting from the database.

Protected Methods

Method Description
clearFromCache ( $key ) Clear an item from the cache completely.
formatValue ( $value, $default ) : mixed Format a settings value
getOverrideValue ( $key ) : boolean | null Returns an override value for a setting based on certain app conditions.
getSettingObjectByKey ( $key ) : mixed Gets a setting model from the database for the given key.
getValueFromStore ( $key, $default ) : mixed Gets a setting value from the cache or database.

Method Details

__construct() public method

SettingService constructor.
public __construct ( Setting $setting, Illuminate\Contracts\Cache\Repository $cache )
$setting BookStack\Setting
$cache Illuminate\Contracts\Cache\Repository

clearFromCache() protected method

Clear an item from the cache completely.
protected clearFromCache ( $key )
$key

formatValue() protected method

Format a settings value
protected formatValue ( $value, $default ) : mixed
$value
$default
return mixed

get() public method

Gets a setting from the database, If not found, Returns default, Which is false by default.
public get ( $key, string | boolean $default = false ) : boolean | string
$key
$default string | boolean
return boolean | string

getOverrideValue() protected method

Used where certain configuration options overrule others. Returns null if no override value is available.
protected getOverrideValue ( $key ) : boolean | null
$key
return boolean | null

getSettingObjectByKey() protected method

Gets a setting model from the database for the given key.
protected getSettingObjectByKey ( $key ) : mixed
$key
return mixed

getValueFromStore() protected method

Looks at the system defaults if not cached or in database.
protected getValueFromStore ( $key, $default ) : mixed
$key
$default
return mixed

has() public method

Checks if a setting exists.
public has ( $key ) : boolean
$key
return boolean

put() public method

Add a setting to the database.
public put ( $key, $value ) : boolean
$key
$value
return boolean

remove() public method

Removes a setting from the database.
public remove ( $key ) : boolean
$key
return boolean

Property Details

$cache protected property

protected $cache

$cachePrefix protected property

protected $cachePrefix

$setting protected property

protected $setting