MetaFox

SiteSettingRepositoryInterface
in

Interface SiteSetting.

Tags
see
Settings

Table of Contents

Methods

bootingKernelConfigs()  : void
Update laravel config() when booting.
createSetting()  : bool
destroy()  : bool
Remove settings from core_site_settings by `module_id` and `name`.
get()  : mixed|null
Get user actual value for specific setting key.
getPrivateEnvironments()  : array<string|int, mixed>
getSiteSettings()  : array<string, array<string, mixed>>
has()  : bool
Check a settings is exists.
keys()  : array<string|int, mixed>
This method is used to generate ide:fix.
loadConfigValues()  : array<string|int, mixed>
refresh()  : void
This method should be call when you want to refresh cached data after saving new values.
reset()  : bool
Reset core_site_settings to value_default by specific $module and name list.
save()  : array<string, mixed>
Save user actual values, only existed name in database can be update.
saveAndCollectPrivateSettings()  : array<string, mixed>
Save setting values and collect all private settings by $privateSettings reference.
setupPackageSettings()  : array<string, mixed>
Create/Update core_site_setting by `name`, and `value_default`.
updatedAt()  : string
Last updated time. this is alias to `get('core.setting_updated_at')`.
updateSetting()  : bool
versionId()  : int
Whenever admin updated revision, we must increment versionId This value is used to publish cache and purge caching data cross multiple distribute server.

Methods

createSetting()

public createSetting(string $module, string $name, string|null $configName, string|null $envVar, mixed $value, string $type, bool $public, bool $auto) : bool
Parameters
$module : string
$name : string
$configName : string|null
$envVar : string|null
$value : mixed
$type : string
$public : bool
$auto : bool
Return values
bool

destroy()

Remove settings from core_site_settings by `module_id` and `name`.

public destroy(string $module[, array<string|int, mixed>|null $names = null ]) : bool

If names is null, remove all by module_id.

Parameters
$module : string
$names : array<string|int, mixed>|null = null
Tags
code

$this->destroy('blog'); // remove all $this->destroy('blog', []); // Not remove anything. $this->destroy('blog',['privacy_enabled']); //

encode
Return values
bool

get()

Get user actual value for specific setting key.

public get(string $key[, mixed $default = null ]) : mixed|null

If value_actual is not exists, it use alternate value_default.

Note: not all data should be saved in to cached because of data size etc: you should not keep 10Kb text string into setting cache because it push to memory at application start time.

Parameters
$key : string
$default : mixed = null
Tags
code

$this->get('blog.privacy_enabled'); // true $this->get('blog.other_name'); // ['data1', 'data2']

encode
Return values
mixed|null

getSiteSettings()

public getSiteSettings(string $for, bool $loadFromDriver) : array<string, array<string, mixed>>
Parameters
$for : string

web, mobile, admin

$loadFromDriver : bool
Return values
array<string, array<string, mixed>>

has()

Check a settings is exists.

public has(string $key) : bool
Parameters
$key : string
Tags
code

$this->has('blog.privacy_enabled'); // true $this->has('blog.invalid_key'); // false

encode
Return values
bool

keys()

This method is used to generate ide:fix.

public keys() : array<string|int, mixed>
Return values
array<string|int, mixed>

refresh()

This method should be call when you want to refresh cached data after saving new values.

public refresh() : void

By default values is loaded from cached. when refresh call it will reload data from database then pull up to cache.

Tags
code

$this->refresh();

endcode

reset()

Reset core_site_settings to value_default by specific $module and name list.

public reset(string $module[, array<string|int, mixed>|null $names = null ]) : bool

if $names is null, it will reset all values for specific module.

Parameters
$module : string
$names : array<string|int, mixed>|null = null
Tags
code

$this->reset('blog', null); // reset all values $this->reset('blog', []); // not reset. $this->reset('blog', ['privacy_enabled']); // reset on ly name="privacy_enabled"

endcode
Return values
bool

save()

Save user actual values, only existed name in database can be update.

public save(array<string, mixed> $values) : array<string, mixed>

It should not create new row.

Parameters
$values : array<string, mixed>
Tags
code

$this->save('blog', [ 'privacy_enabled'=>true, 'other_name' => ['data1', 'data2'] ]);

encode
Return values
array<string, mixed>

saveAndCollectPrivateSettings()

Save setting values and collect all private settings by $privateSettings reference.

public saveAndCollectPrivateSettings(array<string, mixed> $values[, array<string, mixed>|null &$privateSettings = [] ]) : array<string, mixed>
Parameters
$values : array<string, mixed>
$privateSettings : array<string, mixed>|null = []
Return values
array<string, mixed>

setupPackageSettings()

Create/Update core_site_setting by `name`, and `value_default`.

public setupPackageSettings(string $module, array<string, mixed> $settings) : array<string, mixed>
Parameters
$module : string
$settings : array<string, mixed>
Tags
code

$this->create('blog', [ 'privacy_enabled'=> ['value'=> true), 'other_name'=> ['value'=>['data2','data3']], 'sample_description'=> ['value'=>"very large text", 'auto' => false] ]);

encode
Return values
array<string, mixed>

updatedAt()

Last updated time. this is alias to `get('core.setting_updated_at')`.

public updatedAt() : string
Tags
code

$this->updatedAt(); // return "2020-10-04 12:14:12"

encode
Return values
string

updateSetting()

public updateSetting(string $module, string $name, string|null $configName, string|null $envVar, mixed $value, string $type, bool|null $public, bool|null $auto) : bool
Parameters
$module : string
$name : string
$configName : string|null
$envVar : string|null
$value : mixed
$type : string
$public : bool|null
$auto : bool|null
Return values
bool

versionId()

Whenever admin updated revision, we must increment versionId This value is used to publish cache and purge caching data cross multiple distribute server.

public versionId() : int

This is alias of $this->get('core.setting_version_id');

Tags
code

$this->versionId(); // return 11 setting('core.general.site_title'); // return string setting('core.general') ; // return array setting('core'); // null

encode
Return values
int

        
On this page

Search results