Neuron-PHP

SettingManager
in package
implements ISettingSource

Enhanced settings manager with support for multiple ordered sources

Maintains backward compatibility with single source + fallback pattern while also supporting multiple ordered sources for layered configuration.

Table of Contents

Interfaces

ISettingSource
Access to setting based services.

Properties

$additionalSources  : array<string|int, ISettingSource, name: ?string}>
$fallback  : ISettingSource|null
$source  : ISettingSource|null

Methods

__construct()  : mixed
addSource()  : SettingManager
Add an additional source to the stack Sources added later have higher priority
deepMerge()  : array<string|int, mixed>
Recursively merge two arrays (deep merge) Values from $override replace values from $base
get()  : mixed
Get a setting value Checks primary source first, then additional sources, then fallback
getFallback()  : ISettingSource|null
Get the fallback source
getSection()  : array<string|int, mixed>|null
Get entire section as an array from primary source only (Primary source contains all merged configuration)
getSectionNames()  : array<string|int, mixed>
Get all unique section names from all sources
getSectionSettingNames()  : array<string|int, mixed>
Get all unique setting names for a section from all sources
getSource()  : ISettingSource|null
Get the primary source
save()  : bool
Save all saveable sources
set()  : ISettingSource
Set a setting value in the primary source (or last additional source if no primary)
setFallback()  : SettingManager
Set the fallback source
setSource()  : SettingManager
Set the primary source
getAllSources()  : array<string|int, ISettingSource>
Get all configured sources in priority order

Properties

$additionalSources

private array<string|int, ISettingSource, name: ?string}> $additionalSources = []

Additional ordered sources

Methods

addSource()

Add an additional source to the stack Sources added later have higher priority

public addSource(ISettingSource $source[, string|null $name = null ]) : SettingManager
Parameters
$source : ISettingSource

The setting source to add

$name : string|null = null

Optional name for debugging

Return values
SettingManager

Fluent interface

deepMerge()

Recursively merge two arrays (deep merge) Values from $override replace values from $base

public static deepMerge(array<string|int, mixed> $base, array<string|int, mixed> $override) : array<string|int, mixed>
Parameters
$base : array<string|int, mixed>

Base array

$override : array<string|int, mixed>

Array to merge over base

Return values
array<string|int, mixed>

Merged result

get()

Get a setting value Checks primary source first, then additional sources, then fallback

public get(string $section, string $name) : mixed
Parameters
$section : string

Section name

$name : string

Setting name

Return values
mixed

The setting value or null if not found

getSection()

Get entire section as an array from primary source only (Primary source contains all merged configuration)

public getSection(string $section) : array<string|int, mixed>|null
Parameters
$section : string

Section name

Return values
array<string|int, mixed>|null

Section data or null if section doesn't exist

getSectionNames()

Get all unique section names from all sources

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

getSectionSettingNames()

Get all unique setting names for a section from all sources

public getSectionSettingNames(string $section) : array<string|int, mixed>
Parameters
$section : string

Section name

Return values
array<string|int, mixed>

save()

Save all saveable sources

public save() : bool
Return values
bool

True if all saves succeeded

set()

Set a setting value in the primary source (or last additional source if no primary)

public set(string $sectionName, string $name, mixed $value) : ISettingSource
Parameters
$sectionName : string

Section name

$name : string

Setting name

$value : mixed

Setting value

Return values
ISettingSource

Fluent interface

getAllSources()

Get all configured sources in priority order

private getAllSources() : array<string|int, ISettingSource>
Return values
array<string|int, ISettingSource>

Sources from lowest to highest priority


        
On this page

Search results