ConfigMaker

Config Maker Trait Adds configuration based methods to a class

 trait System\Traits\ConfigMaker

Properties

protected $configPath : string

Specifies a path to the config directory.

Methods

public getConfigPath (string $fileName, mixed $configPath = null) : string

Locates a file based on it's definition. If the file starts with the ~ symbol it will be returned in context of the application base path, otherwise it will be returned in context of the config path.

Parameters
Property Description
$fileName
string

File to load.

$configPath
mixed

Explicitly define a config path.

Returns
string

Full path to the config file.

public guessConfigPath (string $suffix = "") : string

Guess the package path for the called class.

Parameters
Property Description
$suffix
string

An extra path to attach to the end

Returns
string

public guessConfigPathFrom (string $class, string $suffix = "") : string

Guess the package path from a specified class.

Parameters
Property Description
$class
string

Class to guess path from.

$suffix
string

An extra path to attach to the end

Returns
string

public makeConfig (array $configFile = [], array $requiredConfig = []) : array | stdClass

Reads the contents of the supplied file and applies it to this object.

Parameters
Property Description
$configFile
array
$requiredConfig
array
Returns
array | stdClass

public makeConfigFromArray (array $configArray = []) : stdClass

Makes a config object from an array, making the first level keys properties of a new object.

Parameters
Property Description
$configArray
array

Config array.

Returns
stdClass

The config object

public mergeConfig (mixed $configA, mixed $configB) : stdClass

Merges two configuration sources, either prepared or not, and returns them as a single configuration object.

Parameters
Property Description
$configA
mixed
$configB
mixed
Returns
stdClass

The config object

Copyright © 2024 Winter CMS