class YamlSource (View source)

Configuration source based on YAML files

Properties

protected bool $usePhpYamlExtension

Will be set if the PHP YAML Extension is installed.

Methods

__construct()

No description

bool
has(string $pathAndFilename, bool $allowSplitSource = false)

Checks for the specified configuration file and returns true if it exists.

array
load(string $pathAndFilename, bool $allowSplitSource = false)

Loads the specified configuration file and returns its content as an array. If the file does not exist or could not be loaded, an empty array is returned

detectFilesWithWrongExtension(string $pathAndFilename, bool $allowSplitSource = false)

No description

array
mergeFileContent(string $pathAndFilename, array $configuration)

Loads the file with the given path and merge it's contents into the configuration array.

void
save(string $pathAndFilename, array $configuration)

Save the specified configuration array to the given file in YAML format.

string
getHeaderFromFile(string $pathAndFilename)

Read the header part from the given file. That means, every line until the first non comment line is found.

Details

__construct()

No description

bool has(string $pathAndFilename, bool $allowSplitSource = false)

Checks for the specified configuration file and returns true if it exists.

Parameters

string $pathAndFilename

Full path and filename of the file to load, excluding the file extension (ie. ".yaml")

bool $allowSplitSource

If true, the type will be used as a prefix when looking for configuration files

Return Value

bool

array load(string $pathAndFilename, bool $allowSplitSource = false)

Loads the specified configuration file and returns its content as an array. If the file does not exist or could not be loaded, an empty array is returned

Parameters

string $pathAndFilename

Full path and filename of the file to load, excluding the file extension (ie. ".yaml")

bool $allowSplitSource

If true, the type will be used as a prefix when looking for configuration files

Return Value

array

Exceptions

ParseErrorException
Exception

protected detectFilesWithWrongExtension(string $pathAndFilename, bool $allowSplitSource = false)

No description

Parameters

string $pathAndFilename
bool $allowSplitSource

Exceptions

Exception

protected array mergeFileContent(string $pathAndFilename, array $configuration)

Loads the file with the given path and merge it's contents into the configuration array.

Parameters

string $pathAndFilename
array $configuration

Return Value

array

Exceptions

ParseErrorException

void save(string $pathAndFilename, array $configuration)

Save the specified configuration array to the given file in YAML format.

Parameters

string $pathAndFilename

Full path and filename of the file to write to, excluding the dot and file extension (i.e. ".yaml")

array $configuration

The configuration to save

Return Value

void

protected string getHeaderFromFile(string $pathAndFilename)

Read the header part from the given file. That means, every line until the first non comment line is found.

Parameters

string $pathAndFilename

Return Value

string

The header of the given YAML file