Config
extends Data
in package
Class Config
Table of Contents
Properties
- $environment : string
- $blueprints : Blueprint|callable|null
- $checksum : string
- $gettersVariable : string
- $items : array<string|int, mixed>
- $key : string
- $modified : bool
- $storage : FileInterface|null
- $timestamp : int
Methods
- __construct() : mixed
- blueprints() : Blueprint
- Return blueprints.
- checksum() : string|null
- debug() : void
- exists() : bool
- Returns whether the data already exists in the storage.
- extra() : array<string|int, mixed>
- Get extra items which haven't been defined in blueprints.
- file() : FileInterface|null
- Set or get the data storage.
- filter() : $this
- Filter all items by using blueprints.
- getDefaults() : array<string|int, mixed>
- Get nested structure containing default values defined in the blueprints.
- getJoined() : array<string|int, mixed>
- Get value from the configuration and join it with given data.
- getLanguages() : mixed
- init() : void
- join() : $this
- Join nested values together by using blueprints.
- joinDefaults() : $this
- Set default values by using blueprints.
- jsonSerialize() : array<string|int, mixed>
- key() : string
- merge() : $this
- Merge two configurations together.
- modified() : bool
- raw() : string
- Return unmodified data as raw string.
- reload() : $this
- save() : void
- Save data if storage has been defined.
- setDefaults() : $this
- Set default values to the configuration if variables were not set.
- setKeepEmptyValues() : $this
- setMissingValuesAsNull() : $this
- timestamp() : int
- validate() : $this
- Validate by blueprints.
- value() : mixed
- Get value by using dot notation for nested arrays/objects.
Properties
$environment
public
string
$environment
$blueprints
protected
Blueprint|callable|null
$blueprints
$checksum
protected
string
$checksum
$gettersVariable
protected
string
$gettersVariable
= 'items'
$items
protected
array<string|int, mixed>
$items
$key
protected
string
$key
$modified
protected
bool
$modified
= false
$storage
protected
FileInterface|null
$storage
$timestamp
protected
int
$timestamp
= 0
Methods
__construct()
public
__construct([array<string|int, mixed> $items = [] ][, Blueprint|callable|null $blueprints = null ]) : mixed
Parameters
- $items : array<string|int, mixed> = []
- $blueprints : Blueprint|callable|null = null
blueprints()
Return blueprints.
public
blueprints() : Blueprint
Return values
Blueprintchecksum()
public
checksum([string|null $checksum = null ]) : string|null
Parameters
- $checksum : string|null = null
Return values
string|nulldebug()
public
debug() : void
exists()
Returns whether the data already exists in the storage.
public
exists() : bool
NOTE: This method does not check if the data is current.
Return values
boolextra()
Get extra items which haven't been defined in blueprints.
public
extra() : array<string|int, mixed>
Return values
array<string|int, mixed>file()
Set or get the data storage.
public
file([FileInterface|null $storage = null ]) : FileInterface|null
Parameters
- $storage : FileInterface|null = null
-
Optionally enter a new storage.
Return values
FileInterface|nullfilter()
Filter all items by using blueprints.
public
filter() : $this
Return values
$thisgetDefaults()
Get nested structure containing default values defined in the blueprints.
public
getDefaults() : array<string|int, mixed>
Fields without default value are ignored in the list.
Return values
array<string|int, mixed>getJoined()
Get value from the configuration and join it with given data.
public
getJoined(string $name, array<string|int, mixed>|object $value[, string $separator = '.' ]) : array<string|int, mixed>
Parameters
- $name : string
-
Dot separated path to the requested value.
- $value : array<string|int, mixed>|object
-
Value to be joined.
- $separator : string = '.'
-
Separator, defaults to '.'
Tags
Return values
array<string|int, mixed>getLanguages()
public
getLanguages() : mixed
Use Grav::instance()['languages'] instead.
init()
public
init() : void
join()
Join nested values together by using blueprints.
public
join(string $name, mixed $value[, string $separator = '.' ]) : $this
Parameters
- $name : string
-
Dot separated path to the requested value.
- $value : mixed
-
Value to be joined.
- $separator : string = '.'
-
Separator, defaults to '.'
Tags
Return values
$thisjoinDefaults()
Set default values by using blueprints.
public
joinDefaults(string $name, mixed $value[, string $separator = '.' ]) : $this
Parameters
- $name : string
-
Dot separated path to the requested value.
- $value : mixed
-
Value to be joined.
- $separator : string = '.'
-
Separator, defaults to '.'
Return values
$thisjsonSerialize()
public
jsonSerialize() : array<string|int, mixed>
Attributes
- #[ReturnTypeWillChange]
Return values
array<string|int, mixed>key()
public
key() : string
Return values
stringmerge()
Merge two configurations together.
public
merge(array<string|int, mixed> $data) : $this
Parameters
- $data : array<string|int, mixed>
Return values
$thismodified()
public
modified([bool|null $modified = null ]) : bool
Parameters
- $modified : bool|null = null
Return values
boolraw()
Return unmodified data as raw string.
public
raw() : string
NOTE: This function only returns data which has been saved to the storage.
Return values
stringreload()
public
reload() : $this
Return values
$thissave()
Save data if storage has been defined.
public
save() : void
Tags
setDefaults()
Set default values to the configuration if variables were not set.
public
setDefaults(array<string|int, mixed> $data) : $this
Parameters
- $data : array<string|int, mixed>
Return values
$thissetKeepEmptyValues()
public
setKeepEmptyValues(bool $value) : $this
Parameters
- $value : bool
Return values
$thissetMissingValuesAsNull()
public
setMissingValuesAsNull(bool $value) : $this
Parameters
- $value : bool
Return values
$thistimestamp()
public
timestamp([int|null $timestamp = null ]) : int
Parameters
- $timestamp : int|null = null
Return values
intvalidate()
Validate by blueprints.
public
validate() : $this
Tags
Return values
$thisvalue()
Get value by using dot notation for nested arrays/objects.
public
value(string $name[, mixed $default = null ][, string $separator = '.' ]) : mixed
Parameters
- $name : string
-
Dot separated path to the requested value.
- $default : mixed = null
-
Default value (or null).
- $separator : string = '.'
-
Separator, defaults to '.'
Tags
Return values
mixed —Value.