Documentation

Setup extends Data
in package

Class Setup

Table of Contents

Properties

$environment  : string|null
$environments  : array<string|int, mixed>
$securityFile  : string
$blueprints  : Blueprint|callable|null
$gettersVariable  : string
$items  : array<string|int, mixed>
$storage  : FileInterface|null
$streams  : array<string|int, mixed>

Methods

__construct()  : mixed
blueprints()  : Blueprint
Return blueprints.
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.
getStreams()  : array<string|int, mixed>
Get available streams and their types from the configuration.
init()  : $this
initializeLocator()  : void
Initialize resource locator by using the configuration.
join()  : $this
Join nested values together by using blueprints.
joinDefaults()  : $this
Set default values by using blueprints.
jsonSerialize()  : array<string|int, mixed>
merge()  : $this
Merge two configurations together.
raw()  : string
Return unmodified data as raw string.
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
validate()  : $this
Validate by blueprints.
value()  : mixed
Get value by using dot notation for nested arrays/objects.
check()  : void

Properties

$environment

public static string|null $environment

Current environment normalized to lower case.

$environments

public static array<string|int, mixed> $environments = ['' => 'unknown', '127.0.0.1' => 'localhost', '::1' => 'localhost']

Environment aliases normalized to lower case.

$securityFile

public static string $securityFile = 'config://security.yaml'

$gettersVariable

protected string $gettersVariable = 'items'

$items

protected array<string|int, mixed> $items

$storage

protected FileInterface|null $storage

$streams

protected array<string|int, mixed> $streams = ['user' => ['type' => 'ReadOnlyStream', 'force' => true, 'prefixes' => ['' => []]], 'cache' => ['type' => 'Stream', 'force' => true, 'prefixes' => [ '' => [], // Set in constructor 'images' => ['images'], ]], 'log' => ['type' => 'Stream', 'force' => true, 'prefixes' => ['' => []]], 'tmp' => ['type' => 'Stream', 'force' => true, 'prefixes' => ['' => []]], 'backup' => ['type' => 'Stream', 'force' => true, 'prefixes' => ['' => []]], 'environment' => ['type' => 'ReadOnlyStream'], 'system' => ['type' => 'ReadOnlyStream', 'prefixes' => ['' => ['system']]], 'asset' => ['type' => 'Stream', 'prefixes' => ['' => ['assets']]], 'blueprints' => ['type' => 'ReadOnlyStream', 'prefixes' => ['' => ['environment://blueprints', 'user://blueprints', 'system://blueprints']]], 'config' => ['type' => 'ReadOnlyStream', 'prefixes' => ['' => ['environment://config', 'user://config', 'system://config']]], 'plugins' => ['type' => 'ReadOnlyStream', 'prefixes' => ['' => ['user://plugins']]], 'plugin' => ['type' => 'ReadOnlyStream', 'prefixes' => ['' => ['user://plugins']]], 'themes' => ['type' => 'ReadOnlyStream', 'prefixes' => ['' => ['user://themes']]], 'languages' => ['type' => 'ReadOnlyStream', 'prefixes' => ['' => ['environment://languages', 'user://languages', 'system://languages']]], 'image' => ['type' => 'Stream', 'prefixes' => ['' => ['user://images', 'system://images']]], 'page' => ['type' => 'ReadOnlyStream', 'prefixes' => ['' => ['user://pages']]], 'user-data' => ['type' => 'Stream', 'force' => true, 'prefixes' => ['' => ['user://data']]], 'account' => ['type' => 'ReadOnlyStream', 'prefixes' => ['' => ['user://accounts']]]]

Methods

__construct()

public __construct(Container|array<string|int, mixed> $container) : mixed
Parameters
$container : Container|array<string|int, mixed>

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
bool

extra()

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|null

filter()

Filter all items by using blueprints.

public filter() : $this
Return values
$this

getDefaults()

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
throws
RuntimeException
Return values
array<string|int, mixed>

getStreams()

Get available streams and their types from the configuration.

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

init()

public init() : $this
Tags
throws
RuntimeException
throws
InvalidArgumentException
Return values
$this

initializeLocator()

Initialize resource locator by using the configuration.

public initializeLocator(UniformResourceLocator $locator) : void
Parameters
$locator : UniformResourceLocator
Tags
throws
BadMethodCallException

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
throws
RuntimeException
Return values
$this

joinDefaults()

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
$this

jsonSerialize()

public jsonSerialize() : array<string|int, mixed>
Attributes
#[ReturnTypeWillChange]
Return values
array<string|int, mixed>

merge()

Merge two configurations together.

public merge(array<string|int, mixed> $data) : $this
Parameters
$data : array<string|int, mixed>
Return values
$this

raw()

Return unmodified data as raw string.

public raw() : string

NOTE: This function only returns data which has been saved to the storage.

Return values
string

save()

Save data if storage has been defined.

public save() : void
Tags
throws
RuntimeException

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
$this

setKeepEmptyValues()

public setKeepEmptyValues(bool $value) : $this
Parameters
$value : bool
Return values
$this

setMissingValuesAsNull()

public setMissingValuesAsNull(bool $value) : $this
Parameters
$value : bool
Return values
$this

validate()

Validate by blueprints.

public validate() : $this
Tags
throws
Exception
Return values
$this

value()

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
example

$value = $data->value('this.is.my.nested.variable');

Return values
mixed

Value.

check()

protected check(UniformResourceLocator $locator) : void
Parameters
$locator : UniformResourceLocator
Tags
throws
InvalidArgumentException
throws
BadMethodCallException
throws
RuntimeException

        
On this page

Search results